update-checker #333
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Commit Changes | |
run: | | |
git config --global user.email "apk-artifacts-downloader@github.com" | |
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 }} | |
if: ${{ env.status == 'success' }} | |
- name: Publish Release | |
uses: softprops/action-gh-release@v2 | |
if: ${{ env.status == 'success' }} | |
with: | |
files: ./archive/*.apk | |
tag_name: ${{ steps.apk-info.outputs.version-name }} | |
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 }} |