Merge pull request #27 from MatrixAI/feature-flake-indirect #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- staging | |
- feature* | |
env: | |
# Caching | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NIX_CACHE_PRIV_KEY: ${{ secrets.NIX_CACHE_PRIV_KEY }} | |
NIX_CACHE_PUB_KEY: ${{ secrets.NIX_CACHE_PUB_KEY }} | |
NIX_CONFIG: access-tokens = github.com=${{ secrets.NIXPKGS_PRIVATE_PAT }} | |
jobs: | |
check-lint: | |
name: "Check / Lint" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
if: > | |
github.ref == 'refs/heads/staging' || | |
contains(github.ref, 'feature') | |
steps: | |
- run: entrypoint | |
- uses: actions/checkout@v4 | |
- name: Lint code | |
run: | | |
nix develop .#ci --command bash -c $' | |
npm run lint --verbose | |
' | |
build-dist: | |
name: "Build / Dist" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: check-lint | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- run: entrypoint | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Build dist | |
env: | |
POLYKEY_NETWORK_STATUS_PROT: 'https' | |
POLYKEY_NETWORK_STATUS_HOST: 'testnet.polykey.com' | |
run: | | |
echo 'Perform static site generation' | |
nix develop .#ci --command bash -c $' | |
npm run build --verbose | |
' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build-public | |
path: ./public | |
build-pull: | |
name: "Build / Pull Request" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: check-lint | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create pull request | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
git config --global --add safe.directory /__w/Polykey-Network-Dashboard/Polykey-Network-Dashboard | |
gh pr create \ | |
--head staging \ | |
--base master \ | |
--title "ci: merge staging to master" \ | |
--body "This is an automatic PR generated by the CI/CD pipeline. This will be automatically fast-forward merged if successful." \ | |
--assignee "@me" \ | |
--no-maintainer-edit || true | |
printf "Pipeline Attempt on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \ | |
| gh pr comment staging \ | |
--body-file - \ | |
--repo "$GH_PROJECT_PATH" | |
integration-build: | |
name: "Integration / Build" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: build-dist | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- run: entrypoint | |
- uses: actions/checkout@v4 | |
with: | |
lfs: true | |
- name: Build dist | |
env: | |
POLYKEY_NETWORK_STATUS_PROT: 'https' | |
POLYKEY_NETWORK_STATUS_HOST: 'mainnet.polykey.com' | |
run: | | |
echo 'Perform static site generation' | |
nix develop .#ci --command bash -c $' | |
npm run build --verbose | |
' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: integration-public | |
path: ./public | |
integration-deployment: | |
name: "Integration / Deployment" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: integration-build | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- run: entrypoint | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-public | |
path: ./public | |
- name: Run deployment | |
env: | |
name: 'preview' | |
deployment_tier: 'staging' | |
url: 'https://testnet.polykey.com' | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
run: | | |
echo 'Perform service deployment for staging' | |
nix develop .#ci --command bash -c $' | |
npm run deploy --verbose -- --env staging | |
' | |
integration-merge: | |
name: "Integration / Merge" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: | |
- build-pull | |
- integration-build | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Merge into master | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} | |
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }} | |
run: | | |
git config --global --add safe.directory /__w/Polykey-Network-Dashboard/Polykey-Network-Dashboard | |
printf "Pipeline Succeeded on $GITHUB_RUN_ID for $GITHUB_SHA\n\n$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \ | |
| gh pr comment staging \ | |
--body-file - \ | |
--repo "$GH_PROJECT_PATH" | |
git checkout master | |
git merge --ff-only "$GITHUB_SHA" | |
git push origin master | |
release-deployment: | |
name: "Release / Deployment" | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/matrixai/github-runner | |
needs: integration-merge | |
if: github.ref == 'refs/heads/staging' | |
steps: | |
- run: entrypoint | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: integration-public | |
path: ./public | |
- name: Run deployment | |
env: | |
name: 'production' | |
deployment_tier: 'production' | |
url: 'https://mainnet.polykey.com' | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
run: | | |
echo 'Perform service deployment for production' | |
nix develop .#ci --command bash -c $' | |
npm run deploy --verbose -- --env production | |
' | |