-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (41 loc) · 1.55 KB
/
deploy-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Deploy Prod
on:
workflow_run:
workflows: ["Build Prod"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup GitHub CLI
run: |
echo "${{ secrets.GITHUB_TOKEN }}" > ~/.github_token
gh auth login --with-token < ~/.github_token
- name: List artifacts
id: list_artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api -H "Accept: application/vnd.github.v3+json" /repos/${{ github.repository }}/actions/artifacts > artifacts.json
- name: Extract artifact URL
id: extract_url
run: |
ARTIFACT_URL=$(jq -r '.artifacts[] | select(.name=="build-artifact-prod") | .archive_download_url' artifacts.json | head -n 1)
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV
- name: Download artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p dist
curl -L -H "Authorization: token $GITHUB_TOKEN" -o artifact.zip ${{ env.ARTIFACT_URL }}
unzip artifact.zip -d dist
- name: Publish Cloudflare
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist --project-name=${{ vars.PROJECT_NAME }} --branch=${{ vars.BRANCH_PROD }} --commit-dirty=true