Skip to content

Merge pull request #106 from MatrixAI/feature-flake-indirect #43

Merge pull request #106 from MatrixAI/feature-flake-indirect

Merge pull request #106 from MatrixAI/feature-flake-indirect #43

Workflow file for this run

name: CI
on:
push:
branches:
- staging
- feature*
jobs:
check-lint:
name: "Check / Lint"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
steps:
- uses: actions/checkout@v4
- name: Run linting
run: |
nix develop .#ci --command bash -c $'
npm run lint
'
check-build:
name: "Check / Build"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Run build
run: |
nix develop .#ci --command bash -c $'
npm run build --verbose
'
- uses: actions/upload-artifact@v4
with:
name: public
path: ./public
check-deployment:
name: "Check / Deployment"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
concurrency:
group: check-deployment
cancel-in-progress: false
environment: feature
needs: check-build
if: startsWith(github.ref, 'refs/heads/feature')
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/download-artifact@v4
with:
name: public
path: ./public
- name: Run deployment
env:
name: "feature/${{ github.ref_name }}"
url: "https://${{ github.ref_name }}.dev.polykey.com/docs"
deployment_tier: 'development'
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
echo 'Perform service deployment for feature'
nix develop .#ci --command bash -c $'
npm run deploy -- \
--feature "$GITHUB_REF_NAME" \
--env "$GITHUB_REF_NAME"
'
build-pull:
name: "Build / Pull Request"
runs-on: ubuntu-latest
needs:
- check-lint
- check-build
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
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-deployment:
name: "Integration / Deployment"
runs-on: ubuntu-latest
container:
image: ghcr.io/matrixai/github-runner
concurrency:
group: integration-deployment
cancel-in-progress: false
environment: staging
needs: [check-lint, check-build]
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/download-artifact@v4
with:
name: public
path: ./public
- name: Run deployment
env:
name: 'staging'
url: 'https://staging.polykey.com/docs/'
deployment_tier: 'staging'
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
nix develop .#ci --command bash -c $'
npm run deploy -- --env staging
'
integration-merge:
name: "Integration / Merge"
runs-on: ubuntu-latest
concurrency:
group: integration-merge
cancel-in-progress: true
needs:
- build-pull
- integration-deployment
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: |
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
concurrency:
group: release-deployment
cancel-in-progress: false
environment: production
needs: integration-merge
if: github.ref == 'refs/heads/staging'
steps:
- uses: actions/checkout@v4
with:
lfs: true
- uses: actions/download-artifact@v4
with:
name: public
path: ./public
- name: Run deployment
env:
name: 'production'
url: 'https://polykey.com/docs/'
deployment_tier: 'production'
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
nix develop .#ci --command bash -c $'
npm run deploy -- --env production
'