|
| 1 | +name: Deploy to staging |
| 2 | +on: |
| 3 | + issue_comment: |
| 4 | + types: [created] |
| 5 | +jobs: |
| 6 | + staging: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + if: ${{ contains(fromJSON('["ajor", "danobi", "fbs", "jordalgo", "tyroguru", "viktormalik"]'), github.actor) && github.event.issue.pull_request && github.event.comment.body == '/stage' }} |
| 9 | + steps: |
| 10 | + - name: Get Pull Request Hash |
| 11 | + id: sha |
| 12 | + uses: actions/github-script@v7 |
| 13 | + with: |
| 14 | + result-encoding: string |
| 15 | + script: | |
| 16 | + const {owner, repo, number} = context.issue |
| 17 | + const pr = await github.rest.pulls.get({ |
| 18 | + owner, |
| 19 | + repo, |
| 20 | + pull_number: number, |
| 21 | + }); |
| 22 | + return pr.data.head.sha |
| 23 | + - name: Checkout current branch |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + ref: ${{ steps.sha.outputs.result }} |
| 27 | + fetch-depth: 0 |
| 28 | + - name: Rebase website-staging |
| 29 | + run: | |
| 30 | + git config --global user.name 'Staging Sync' |
| 31 | + git config --global user.email '' |
| 32 | + git checkout -b current |
| 33 | + git clone https://bpftrace:${{ secrets.SYNC_WEBSITE_STAGING }}@github.com/bpftrace/website-staging.git |
| 34 | + cd website-staging |
| 35 | + git remote add pr ../ |
| 36 | + git fetch pr |
| 37 | + git reset --hard pr/current |
| 38 | + git cherry-pick origin/staging-config |
| 39 | + git push -f |
| 40 | + - name: Message success |
| 41 | + if: ${{ success() }} |
| 42 | + uses: actions/github-script@v7 |
| 43 | + with: |
| 44 | + script: | |
| 45 | + github.rest.issues.createComment({ |
| 46 | + issue_number: context.issue.number, |
| 47 | + owner: context.repo.owner, |
| 48 | + repo: context.repo.repo, |
| 49 | + body: 'Deploying pull request to https://staging.bpftrace.org/', |
| 50 | + }); |
0 commit comments