Update File Hash #648
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 File Hash | |
on: | |
schedule: | |
- cron: '0 * * * *' # runs hourly at midnight UTC | |
workflow_dispatch: # so it can run manually | |
repository_dispatch: | |
types: | |
- discordo-ci-completed # Triggered by another repository's GitHub Actions | |
jobs: | |
update-hash: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download ZIP file | |
run: | | |
curl -L -O https://nightly.link/ayn2op/discordo/workflows/ci/main/discordo_Windows_X64.zip | |
- name: Calculate hash of ZIP file | |
id: calculate-hash | |
run: | | |
HASH=$(sha256sum discordo_Windows_X64.zip | awk '{ print $1 }') | |
echo "HASH=$HASH" >> $GITHUB_ENV | |
- name: Update hash in JSON file | |
run: | | |
jq --arg hash "$HASH" '.hash = $hash' bucket/discordo.json > tmp.json && mv tmp.json bucket/discordo.json | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
if ! git diff --exit-code bucket/discordo.json; then | |
git add bucket/discordo.json | |
git commit -m "Update hash in discordo.json" | |
git push | |
else | |
echo "No changes to commit." | |
fi |