Skip to content

Commit ccbdce1

Browse files
committed
ci: create tag by package on update
Signed-off-by: Camber Huang <camber@poi.science>
1 parent 8d2a540 commit ccbdce1

File tree

3 files changed

+84
-22
lines changed

3 files changed

+84
-22
lines changed

.github/workflows/periodic-update.yml

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@ on:
1111
jobs:
1212
update:
1313
runs-on: ubuntu-latest
14-
14+
outputs:
15+
updated: ${{ steps.deploy-file.outputs.deployment-status }}
16+
sha: ${{ steps.get-sha.outputs.sha }}
1517
steps:
1618
- name: Get current time
1719
uses: srfrnk/current-time@master
1820
id: current-time
1921
with:
2022
format: "YYYY-MM-DD HH:mm"
21-
2223
- name: Checkout
23-
uses: actions/checkout@v3
24-
24+
uses: actions/checkout@v4
2525
- name: Update
2626
run: |
2727
bash update-files.sh
28-
2928
- name: Push
3029
uses: JamesIves/github-pages-deploy-action@v4
3130
id: deploy-file
@@ -35,7 +34,6 @@ jobs:
3534
git-config-name: github-actions[bot]
3635
git-config-email: 41898282+github-actions[bot]@users.noreply.github.com
3736
commit-message: updated ${{ steps.current-time.outputs.formattedTime }} UTC
38-
3937
- name: tagging-get-current-time
4038
if: ${{ steps.deploy-file.outputs.deployment-status == 'success' }}
4139
uses: srfrnk/current-time@master
@@ -50,3 +48,51 @@ jobs:
5048
CUSTOM_TAG: ${{ steps.current-time-tagging.outputs.formattedTime }}
5149
DEFAULT_BRANCH: master
5250
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
52+
53+
push_tag:
54+
runs-on: ubuntu-latest
55+
needs: [ update ]
56+
# 仅在有 Push 时
57+
if: ${{ needs.update.outputs.updated == 'success' }}
58+
strategy:
59+
matrix:
60+
item: ['iana-etc', 'bind'] # TODO: 修改为 based by files.list
61+
steps:
62+
- name: Sleep to wait for GitHub process output
63+
run: |
64+
sleep 10s
65+
- name: checkout
66+
uses: actions/checkout@v4
67+
with:
68+
fetch-depth: 0
69+
ref: refs/heads/master
70+
71+
- name: tagging-get-current-time
72+
uses: srfrnk/current-time@master
73+
id: current-time-tagging
74+
with:
75+
format: "YYYYMMDD"
76+
- name: Get current time
77+
uses: srfrnk/current-time@master
78+
id: current-time
79+
with:
80+
format: "YYYY-MM-DD HH:mm"
81+
- name: Push
82+
uses: JamesIves/github-pages-deploy-action@v4
83+
id: deploy-file
84+
with:
85+
branch: ${{ matrix.item }}
86+
folder: ${{ matrix.item }}
87+
git-config-name: github-actions[bot]
88+
git-config-email: 41898282+github-actions[bot]@users.noreply.github.com
89+
commit-message: "chore(ci): updated ${{ matrix.item }} ${{ steps.current-time.outputs.formattedTime }} UTC"
90+
91+
- name: Tagging
92+
if: ${{ steps.deploy-file.outputs.deployment-status == 'success' }}
93+
uses: anothrNick/github-tag-action@1.75.0
94+
env:
95+
CUSTOM_TAG: ${{ matrix.item }}-${{ steps.current-time-tagging.outputs.formattedTime }}
96+
DEFAULT_BRANCH: ${{ matrix.item }}
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+

files.list

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
https://www.internic.net/zones/named.root
1+
bind https://www.internic.net/zones/named.root
22

3-
https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml
4-
https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
3+
iana-etc https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml
4+
iana-etc https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml

update-files.sh

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
#!/bin/bash
22

3-
echo '[+] Removing old files ...'
4-
for i in `cat files.list`; do
5-
rm -v $(basename $i)
6-
done
7-
rm -v *.sha256sum
3+
while IFS= read -r file; do
4+
[[ -z "$file" || "${file:0:1}" == "#" ]] && continue
5+
_arr=($file)
6+
dir=${_arr[0]}
7+
url=${_arr[1]}
8+
filename=${_arr[2]:-$(basename "$url")}
9+
echo "[+] Removing old file $dir/$(basename $filename) ..."
10+
rm -v $dir/$filename{,.sha256sum}
11+
echo "[+] Downloading file $dir/$(basename $filename) ..."
12+
mkdir -p $dir
13+
curl -Lo $dir/$filename $url
14+
echo "[+] Creating checksum (sha256) for $dir/$filename ..."
15+
sha256sum $dir/$filename \
16+
> $dir/$filename.sha256sum
17+
done < files.list
818

9-
echo '[+] Downloading files ...'
10-
wget -i files.list
11-
12-
echo '[+] Creating checksums (sha256) ...'
13-
for i in `cat files.list`; do
14-
sha256sum $(basename $i) \
15-
> $(basename $i).sha256sum
16-
done
19+
# echo '[+] Removing old files ...'
20+
# for i in `cat files.list`; do
21+
# rm -v $(basename $i)
22+
# done
23+
# rm -v *.sha256sum
24+
#
25+
# echo '[+] Downloading files ...'
26+
# wget -i files.list
27+
#
28+
# echo '[+] Creating checksums (sha256) ...'
29+
# for i in `cat files.list`; do
30+
# sha256sum $(basename $i) \
31+
# > $(basename $i).sha256sum
32+
# done

0 commit comments

Comments
 (0)