-
-
Notifications
You must be signed in to change notification settings - Fork 12
62 lines (52 loc) · 1.92 KB
/
Copy pathdeploy_release.yml
File metadata and controls
62 lines (52 loc) · 1.92 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
name: deploy-release-to-pages
on:
release:
types: [published, edited]
workflow_dispatch:
jobs:
deploy-to-pages:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Clear fw directory
run: |
if [ -d "fw" ]; then
rm -rf fw/*
fi
mkdir -p fw
- name: Download release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# get latest release info
LATEST_RELEASE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
RELEASE_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
echo "Downloading $RELEASE_TAG assets"
# download all assets from latest release
echo "$LATEST_RELEASE" | jq -r '.assets[] | "\(.url) \(.name)"' \
| while read url filename; do
echo "Downloading $filename from $url"
curl -L -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/octet-stream" "$url" -o "fw/$filename"
done
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add fw/
# get the latest release tag for commit message
LATEST_TAG=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" \
| jq -r '.tag_name')
git commit -m "Update fw files to $LATEST_TAG" || exit 0
git push