PohlmanProtean is a TypeScript-based Next.js web application hosted on Google Cloud. This project supports both production and development environments, with automated deployments triggered via GitHub workflows.
- Project Overview
- Environments
- Technologies Used
- Setup and Installation
- Running the Project Locally
- Deployment
- DNS Registration
- Manual Deployment
- Release
- Contributing
- Fork the repository
- License
This project is a TypeScript Next.js application for the PohlmanProtean website. The primary URL for production is pohlmanprotean.se, with the development environment accessible at dev.pohlmanprotean.se.
The project is hosted in Google Cloud with continuous deployment handled by GitHub workflows.
| Environment | URL | Description |
|---|---|---|
| Production | pohlmanprotean.se | Live production site |
| Development | dev.pohlmanprotean.se | Staging for new changes |
- Production: Automatically deployed from the
mainbranch to the production URL. - Development: Automatically deployed from the
devbranch to the development URL.
The GitHub workflow file responsible for deployments is located at .github/workflows/deploy.yml.
- Next.js - React framework for server-side rendering and static site generation.
- TypeScript - Superset of JavaScript with static typing.
- Google Cloud - Hosting and cloud services.
- GitHub Workflows - For CI/CD and automatic deployments.
- Clone the repository:
git clone git@github.com:Ridvan-bot/website.git cd website/pohlmanprotean.se/ npm install npm run dev
The project should now be running at http://localhost:3000
To setup everything you need in Google Cloud please visit the shared workflow repo and read the README. https://github.com/Ridvan-bot/workflows/blob/main/README.md
You will find the most relevant information at Prep GCLOUD Workflow
This project uses GitHub Actions to validate code quality before deployment. The validation process includes running ESLint and unit tests to ensure code quality and functionality.
The code quality validation workflow is defined in .github/workflows/validate.yml. This workflow is triggered on every push to the main and dev branches by workflow .github/workflows/deploy.yml.
The validation workflow performs the following steps:
- ESLint: Lints the codebase using ESLint to ensure code quality and consistency.
- Unit Tests: Runs unit tests to verify the functionality of the code.
The validation workflow can be configured using the following inputs:
branches: The branch to run the shared workflow on (default:main).eslint-enable: Enable or disable ESLint (default:false).eslint-command: The command to run ESLint (default:npx eslint --config eslint.config.mjs '**/*.{js,ts,tsx}' || exit 1).unit-test-enable: Enable or disable unit tests (default:true).unit-test-command: The command to run unit tests (default:npm run test).
The validation workflow requires the following secrets:
GH_TOKEN: GitHub token for authentication.
For more details, refer to the validation workflow file.
The Google Cloud run requiers following secrets:
DEV_GCP_SA_KEY: Development Project Google Cloud Json Key.MAIN_GCP_SA_KEY: Production Project Google Cloud Json Key.
This project also use Google Cloud Secret Manager. Add your local secretes here.
The Semantic Release has an option to post release info in Slack Channel:
SLACK_WEBHOOK: Key to pass relese content to Slack Channel.
Automatic Deployment with GitHub Workflows This project uses GitHub Actions to handle automatic deployments:
Production: Any push to the main branch triggers a deployment to pohlmanprotean.se. Development: Any push to the dev branch triggers a deployment to dev.pohlmanprotean.se. The deployment process is defined in .github/workflows/deploy.yml.
Make sure you create a project in Google Gloud Run before you try to commit any code to a repo. Once you pushed the code, and if it failes, make sure the service account in Google Cloud has all the permission it needs. These are the Permissions:
Viewer, Cloud Run Admin, Cloud Build Editor, Service Account User, Storage Admin, Artifact Registry Writer, Registry Administrator.
If you are new to Google Cloud Run, and you are using the free trail, make sure you enable billing.
- Visit Google Cloud
- Navigate to your Project
- Search for Custom Domains (App Engine)
- Create Application
- Choose Region
- Select your Service Account
- Click Next
- Once it completes, search for custom daomains again.
- Add a custom domain
- Type the DNS name
- Click verify
- Use TXT and add that entries in you Domain providers record as TXT
- Wait for 1h and try to verify
- When the verification works, link you domain to your google cloud run
- You will get a list of A records and AAAA recrods by google and CNAME
- Add those records in you Domain providers DNS settings
- You have to remove the old record that you had poiting towards verification URL
- Go to cloud Run
- Mark the Service that you want to mapp
- A menu above the service will be visible
- Click on Domains Mapping
- Click on Add Mapping
- Add the values in your DNS settings at the Domain vendors website, if you haven’t already
In cases where a manual deployment is needed, you can trigger the workflow directly from the GitHub Actions tab on your repository.
This project follows a standardized release and versioning process using Semantic Release to ensure consistent commit messages, making it easier to track changes and automate versioning.
The changelog is automatically generated and maintained using standard-version. With each release, a new version is generated, and an entry is added to CHANGELOG.md.
Make sure all commit messages follow the Semantic Release format.
A new changelog entry in CHANGELOG.md. A new Git tag and GitHub release. Deploy the latest version to the appropriate environment. Post a release message in Slack (Optional)
We welcome contributions to PohlmanProtean! To contribute please contact us via the webpage.
To contribute: Fork the repository. Create a new branch with a descriptive name (feature/your-feature-name). Make your changes and commit them with clear, concise messages. Push your branch and create a pull request.
Crafted with care by Robin Pohlman at Pohlman Protean AB.