Reapply "fix: rename setup script" #61
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 / Application JS Cloudflare Staging" | ||
on: | ||
workflow_call: | ||
inputs: | ||
ref: | ||
type: string | ||
default: master | ||
description: > | ||
Reference used for this repository, so we can re-use it when | ||
referencing local actions, and avoid having to checkout this | ||
repository separately. | ||
secrets: | ||
NIXPKGS_PRIVATE_PAT: | ||
required: true | ||
DEPLOY_SECRETS: | ||
required: true | ||
GITHUB_TOKEN: | ||
Check failure on line 18 in .github/workflows/application-js-cloudflare-staging.yml
|
||
required: true | ||
GIT_AUTHOR_EMAIL: | ||
required: true | ||
GIT_AUTHOR_NAME: | ||
required: true | ||
GIT_COMMITTER_EMAIL: | ||
required: true | ||
GIT_COMMITTER_NAME: | ||
required: true | ||
jobs: | ||
# Lint the code | ||
staging-lint: | ||
name: "Staging / Lint" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
- uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master | ||
- name: Run linting | ||
env: | ||
NIX_CONFIG: access-tokens = github.com=${{ secrets.NIXPKGS_PRIVATE_PAT }} | ||
run: | | ||
nix develop .#ci --command bash -c $' | ||
npm run lint | ||
' | ||
# Create the merge PR | ||
staging-merge-begin: | ||
name: "Staging / Merge Begin" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create Pull Request from Staging to Master | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_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 "$GITHUB_REPOSITORY" | ||
# Build the public - JS is platform-agnostic | ||
staging-build: | ||
name: "Staging / Build" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
actions: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
- uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master | ||
- name: Run build | ||
env: | ||
NIX_CONFIG: access-tokens = github.com=${{ secrets.NIXPKGS_PRIVATE_PAT }} | ||
run: | | ||
nix develop .#ci --command bash -c $' | ||
npm run build --verbose | ||
' | ||
- name: Upload Build | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: public | ||
path: ./public | ||
# Deploy the public | ||
staging-deployment: | ||
name: "Staging / Deployment" | ||
runs-on: ubuntu-latest | ||
needs: staging-build | ||
concurrency: | ||
group: staging-deployment | ||
cancel-in-progress: false | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout Actions | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: MatrixAI/.github | ||
ref: ${{ inputs.ref }} | ||
path: tmp/.github | ||
- uses: MatrixAI/.github/.github/actions/matrixai-env-setup@master | ||
- name: Parse Secrets | ||
uses: ./tmp/.github/.github/actions/secrets-parse | ||
with: | ||
secrets: ${{ secrets.DEPLOY_SECRETS }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: public | ||
path: ./public | ||
- name: Run deployment | ||
env: | ||
NIX_CONFIG: access-tokens = github.com=${{ secrets.NIXPKGS_PRIVATE_PAT }} | ||
run: | | ||
echo 'Perform service deployment for staging' | ||
nix develop .#ci --command bash -c $' | ||
npm run deploy -- --env staging | ||
' | ||
staging-merge-finish: | ||
name: "Staging / Merge Finish" | ||
needs: | ||
- staging-lint | ||
- staging-merge-begin | ||
- staging-build | ||
- staging-deployment | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: staging-merge-finish | ||
cancel-in-progress: true | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Merge Pull Request from Staging to Master | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_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 "$GITHUB_REPOSITORY" | ||
git checkout master | ||
git merge --ff-only "$GITHUB_SHA" | ||
git push origin master |