-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (62 loc) · 2.29 KB
/
Copy pathdeploy.yml
File metadata and controls
69 lines (62 loc) · 2.29 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
repository_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
WC_CONSUMER_KEY: ${{ secrets.WC_CONSUMER_KEY }}
WC_CONSUMER_SECRET: ${{ secrets.WC_CONSUMER_SECRET }}
steps:
- uses: actions/checkout@v4
- name: Find merged PR
id: pr
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
data=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls \
--jq '[.[] | select(.merged_at != null)] | .[0] | {number: .number, title: .title}' \
2>/dev/null || echo 'null')
echo "data=$data" >> "$GITHUB_OUTPUT"
- name: Comment starting deploy on PR
if: steps.pr.outputs.data != 'null' && steps.pr.outputs.data != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr_number=$(echo '${{ steps.pr.outputs.data }}' | jq -r '.number // empty')
[ -n "$pr_number" ] && gh pr comment "$pr_number" \
--repo ${{ github.repository }} \
--body $'🚀 Starting production deploy of site header and footer fragments...'
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
- run: composer i
- run: composer prod
- name: Store deployment info
if: success()
run: |
pr_number=$(echo '${{ steps.pr.outputs.data }}' | jq -r '.number // empty')
pr_title=$(echo '${{ steps.pr.outputs.data }}' | jq -r '.title // ""')
jq -n \
--arg sha "${{ github.sha }}" \
--arg repo "${{ github.repository }}" \
--arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg title "$pr_title" \
--argjson num "${pr_number:-null}" \
'{commit_sha: $sha, pr_number: $num, pr_title: $title, repository: $repo, timestamp: $ts}' \
> build_production/_deployment-info.json
- uses: crazy-max/ghaction-github-pages@v4
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
build_dir: build_production
fqdn: libresign.coop
jekyll: false