Wraith CI #64797
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: Wraith CI | |
on: | |
workflow_dispatch: | |
inputs: | |
payload: | |
required: true | |
env: | |
GH_TOKEN: ${{ fromJson(inputs.payload).token }} | |
repository: ${{ fromJson(inputs.payload).owner }}/${{ fromJson(inputs.payload).repo }} | |
ref: ${{ fromJson(inputs.payload).data.ref }} | |
jobs: | |
wraith-ci: | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [build, deploy, docs, format, lint, merge, release, bump, assign] | |
timeout-minutes: 15 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
token: ${{ env.GH_TOKEN }} | |
repository: ${{ env.repository }} | |
ref: ${{ env.ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: 20 | |
registry-url: https://registry.npmjs.org/ | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
run_install: | | |
recursive: true | |
- name: Ghost ${{ matrix.name }} | |
uses: jill64/wraith-ci@main | |
with: | |
payload: ${{ inputs.payload }} | |
name: ${{ matrix.name }} | |
run_attempt: ${{ github.run_attempt }} | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ matrix.name == 'deploy' && secrets.CLOUDFLARE_API_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ matrix.name == 'release' && secrets.NPM_TOKEN }} | |
try-repair-lock: | |
needs: wraith-ci | |
if: failure() | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 | |
with: | |
token: ${{ env.GH_TOKEN }} | |
repository: ${{ env.repository }} | |
ref: ${{ env.ref }} | |
- name: Setup Node.js | |
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: 20 | |
- name: Try pnpm install | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
run_install: | | |
recursive: true | |
- name: Delete pnpm-lock.yaml | |
if: failure() | |
run: rm -f pnpm-lock.yaml | |
- name: Setup pnpm | |
if: failure() | |
uses: pnpm/action-setup@v2 | |
with: | |
version: latest | |
run_install: | | |
recursive: true | |
- name: Staging | |
if: failure() | |
run: git add pnpm-lock.yaml | |
- name: Push | |
if: failure() | |
run: | | |
if [ $(git diff --cached --name-only) ]; then | |
git config user.name wraith-ci[bot] | |
git config user.email wraith-ci[bot]@users.noreply.github.com | |
git commit -m "chore: repair pnpm-lock.yaml" | |
git pull --rebase | |
git push origin | |
fi | |
post-process: | |
needs: [try-repair-lock, wraith-ci] | |
if: always() | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Close Check Run | |
run: | | |
gh api \ | |
--method PATCH \ | |
/repos/${{ env.repository }}/check-runs/${{ fromJson(inputs.payload).check_run_id }} \ | |
--field status=completed \ | |
--field conclusion=${{ needs.wraith-ci.result }} | |
- name: Revoke Installation Token | |
run: gh api --method DELETE /installation/token | |
- name: Revoke App Token | |
run: gh api --method DELETE /installation/token | |
env: | |
GH_TOKEN: ${{ fromJson(inputs.payload).app_token }} |