element-call-Github/.github/workflows/pr-deploy.yaml

51 lines
2.0 KiB
YAML
Raw Permalink Normal View History

2024-04-13 04:34:08 +08:00
name: PR Preview Deployments
on:
workflow_run:
workflows: ["Build"]
types:
- completed
jobs:
prdetails:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }}
runs-on: ubuntu-latest
2024-04-13 04:45:28 +08:00
outputs:
2024-04-13 04:34:08 +08:00
pr_number: ${{ steps.prdetails.outputs.pr_id }}
pr_data_json: ${{ steps.prdetails.outputs.data }}
2024-04-13 04:45:28 +08:00
steps:
- id: prdetails
2024-06-21 21:21:08 +08:00
uses: matrix-org/pr-details-action@15bde5285d7850ba276cc3bd8a03733e3f24622a # v1.3
2024-04-13 04:45:28 +08:00
continue-on-error: true
with:
owner: ${{ github.event.workflow_run.head_repository.owner.login }}
branch: ${{ github.event.workflow_run.head_branch }}
2024-04-13 04:34:08 +08:00
2024-04-13 05:22:49 +08:00
netlify:
needs: prdetails
2024-04-17 21:18:49 +08:00
permissions:
deployments: write
2024-04-13 05:22:49 +08:00
uses: ./.github/workflows/netlify.yaml
2024-04-13 05:27:34 +08:00
with:
2024-04-23 22:46:26 +08:00
artifact_run_id: ${{ github.event.workflow_run.id || github.run_id }}
2024-04-13 05:22:49 +08:00
pr_number: ${{ needs.prdetails.outputs.pr_number }}
pr_head_full_name: ${{ github.event.workflow_run.head_repository.full_name }}
pr_head_ref: ${{ needs.prdetails.outputs.pr_data_json && fromJSON(needs.prdetails.outputs.pr_data_json).head.ref }}
deployment_ref: ${{ needs.prdetails.outputs.pr_data_json && fromJSON(needs.prdetails.outputs.pr_data_json).head.sha || github.ref || github.head_ref }}
secrets:
ELEMENT_BOT_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
2024-04-13 05:57:18 +08:00
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
docker:
if: ${{ needs.prdetails.outputs.pr_data_json && contains(fromJSON(needs.prdetails.outputs.pr_data_json).labels.*.name, 'docker build') }}
needs: prdetails
permissions:
contents: write
packages: write
2024-04-13 05:57:18 +08:00
uses: ./.github/workflows/docker.yaml
with:
2024-04-23 22:46:26 +08:00
artifact_run_id: ${{ github.event.workflow_run.id || github.run_id }}
2024-04-13 05:57:18 +08:00
docker_tags: |
type=sha,format=short,event=branch
type=raw,value=pr_${{ needs.prdetails.outputs.pr_number }}