|
1 | 1 | # Deploys the static app to GitHub Pages. |
2 | | -# Triggered on push to `main`. |
| 2 | +# Triggered on push to `main`, or can be triggered manually with specific branch. |
3 | 3 | # Requires the secrets (`CI_APP_ID`, `CI_APP_PRIVATE_KEY`) to be configured. |
4 | 4 |
|
5 | 5 | name: Deploy to GitHub Pages |
6 | 6 | on: |
7 | 7 | push: |
8 | 8 | branches: |
9 | 9 | - main |
| 10 | + - deploy-to-php |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + branch: |
| 14 | + description: "Branch to deploy" |
| 15 | + required: false |
| 16 | + default: "main" |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
10 | 20 |
|
11 | 21 | env: |
12 | 22 | NODE_VERSION: 24.x |
|
17 | 27 | env: |
18 | 28 | NODE_OPTIONS: "--max_old_space_size=8192" |
19 | 29 | steps: |
20 | | - - name: Generate Github Token for CI Bot |
| 30 | + - name: Check GitHub App secrets |
| 31 | + id: check-secrets |
| 32 | + env: |
| 33 | + CI_APP_ID: ${{ secrets.CI_APP_ID }} |
| 34 | + CI_APP_PRIVATE_KEY: ${{ secrets.CI_APP_PRIVATE_KEY }} |
| 35 | + if: ${{ env.CI_APP_ID != '' && env.CI_APP_PRIVATE_KEY != '' }} |
| 36 | + run: echo "available=true" >> $GITHUB_OUTPUT |
| 37 | + |
| 38 | + - name: Generate GitHub App token |
| 39 | + if: ${{ steps.check-secrets.outputs.available == 'true' }} |
21 | 40 | uses: actions/create-github-app-token@v1 |
22 | 41 | id: generate-token |
23 | 42 | with: |
|
27 | 46 | - name: Checkout code |
28 | 47 | uses: actions/checkout@v4 |
29 | 48 | with: |
30 | | - token: ${{ steps.generate-token.outputs.token }} |
| 49 | + ref: ${{ github.event.inputs.branch || 'main' }} |
| 50 | + token: ${{ steps.generate-token.outputs.token || github.token }} |
31 | 51 |
|
32 | 52 | - name: Use Node.js |
33 | 53 | uses: actions/setup-node@v4 |
|
40 | 60 | run: npm ci |
41 | 61 |
|
42 | 62 | - name: Deploy |
| 63 | + env: |
| 64 | + DEPLOY_TOKEN: ${{ steps.generate-token.outputs.token || github.token }} |
43 | 65 | run: | |
44 | | - git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git |
| 66 | + git remote set-url origin https://git:${DEPLOY_TOKEN}@github.com/${{github.repository}}.git |
45 | 67 | npm run deploy -- -u "github-actions-bot <support+actions@github.com>" |
46 | | - env: |
47 | | - GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
|
0 commit comments