-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 5.41 KB
/
checker.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: update-checker
on:
workflow_dispatch:
env:
status: failure
workflow_name: none
apk-path: none
repo-title: none
jobs:
check_for_update:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Run Main.go
id: run-main
run: |
go run ./src/main.go --token="${{ secrets.GITHUB_TOKEN }}"
- name: Set Environment Variables
run: |
echo "status=$(jq -r '.status' data/info.json)" >> $GITHUB_ENV
echo "workflow_name=$(jq -r '.workflow.title' data/info.json)" >> $GITHUB_ENV
echo "repo-title=$(jq -r '.workflow.repo' data/settings.json)" >> $GITHUB_ENV
echo "apk-path=$(ls -S archive/*.apk | head -n 1)" >> $GITHUB_ENV
- name: Make Commit Log
run: |
echo "$(jq -r '.["commit-log"]' data/info.json)" > ./data/commit-log.txt
- name: Get Apk Info
id: apk-info
if: ${{ env.status == 'success' }}
uses: hkusu/apk-info-action@v1
with:
apk-path: ${{ env.apk-path }}
- name: Show apk info
run: |
echo '${{ steps.apk-info.outputs.application-name }}'
echo '${{ steps.apk-info.outputs.application-id }}'
echo '${{ steps.apk-info.outputs.version-code }}'
echo '${{ steps.apk-info.outputs.version-name }}'
echo '${{ steps.apk-info.outputs.min-sdk-version }}'
echo '${{ steps.apk-info.outputs.target-sdk-version }}'
echo '${{ steps.apk-info.outputs.compile-sdk-version }}'
echo '${{ steps.apk-info.outputs.uses-permissions }}'
echo '${{ steps.apk-info.outputs.debuggable }}'
echo '${{ steps.apk-info.outputs.allow-backup }}'
echo '${{ steps.apk-info.outputs.supports-rtl }}'
echo '${{ steps.apk-info.outputs.file-size }}'
echo '${{ steps.apk-info.outputs.readable-file-size }}'
- name: Generate release tag
id: generate_release_tag
uses: amitsingh-007/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag_prefix: 'nightly-${{ steps.apk-info.outputs.version-code }}-'
tag_template: 'yyyy.mm.dd.i'
- name: Commit Changes
run: |
git config --global user.email "[email protected]"
git config --global user.name "${{ github.repository_owner }}"
git add .
git commit -m "Update ${{ env.repo-title }} to latest version"
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Delete Old Releases
run: |
releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases | jq -r '.[] | .id' | sort -nr)
for release in $releases; do
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/releases/$release
done
if: ${{ env.status == 'success' }}
- name: Delete Old Tags
run: |
tags=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[] | .name')
for tag in $tags; do
curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$tag
done
if: ${{ env.status == 'success' }}
- name: Publish Release
uses: softprops/action-gh-release@v2
if: ${{ env.status == 'success' }}
with:
files: ./archive/*.apk
tag_name: ${{ steps.generate_release_tag.outputs.next_release_tag }}
name: ${{ env.workflow_name }}
body_path: ./data/commit-log.txt
rerun-workflow:
name: Re-run workflow
needs: check_for_update
if: success() || failure()
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Wait for 5 minutes
run: |
elapsed_time=$(jq -r '.["elapsed-time"]' data/info.json)
if [ $elapsed_time -lt 300 ]; then
sleep $((300 - elapsed_time))
fi
- name: Re-trigger workflow
run: gh workflow run checker.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}