Regularly Scheduled GitHub Actions π Diff Workflow #36
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: GitHub Actions Diff | |
run-name: Regularly Scheduled GitHub Actions π Diff Workflow | |
on: | |
push: | |
schedule: | |
#Run at :39 9AM every day of every month | |
- cron: '39 9 * * *' | |
jobs: | |
Check-for-diffs-ads-txt: | |
runs-on: ubuntu-latest | |
outputs: | |
diffOut: ${{ steps.diff-adstxt-files.outputs.DIFF_OUT }} | |
steps: | |
- run: echo "π The job was automatically triggered by scheduled cron event." | |
- run: echo "π§ This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- run: echo "π Attempting to diff url contents" | |
- name: Diff | |
id: diff-adstxt-files | |
# https://trstringer.com/github-actions-multiline-strings/ | |
# TO MANUALLY UPDATE FILE, VISIT PLAYWIRE URL BELOW AND CTRL+C, THEN CTRL+V INTO ads.txt | |
run: | | |
DIFF_OUT=$(cat << EOF | |
`diff --ignore-all-space <(sed 's/\r//g' <(curl https://config.playwire.com/dyn_ads/1025030/74482/ads.txt)) <(sed 's/\r//g' <(curl https://pvpivs.com/ads.txt))` | |
EOF | |
) | |
echo "DIFF_OUT<<EOF" >> $GITHUB_OUTPUT | |
echo "$DIFF_OUT" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
diff --ignore-all-space <(sed 's/\r//g' <(curl https://config.playwire.com/dyn_ads/1025030/74482/ads.txt)) <(sed 's/\r//g' <(curl https://pvpivs.com/ads.txt)) | |
- run: echo "π‘ Diff completed, diff outcome is ${{ steps.diff-adstxt-files.outcome }}." | |
- run: echo "π This job's status is ${{ job.status }}." | |
Update-ads-txt-after-failed-diff: | |
if: failure() | |
needs: Check-for-diffs-ads-txt | |
runs-on: ubuntu-latest | |
#permissions: | |
#contents: write | |
#pull-requests: write | |
steps: | |
- run: echo "The diff failed, differences are below." | |
- run: echo "${{needs.Check-for-diffs-ads-txt.outputs.diffOut}}" | |
#- run: echo "Proceeding to replace ads.txt..." | |
# https://stackoverflow.com/a/58393457 | |
#- uses: actions/checkout@v3 | |
# with: | |
# ref: gh-pages | |
#repo-token: ${{ secrets.GITHUB_TOKEN }} | |
#- name: Get Updated ads.txt file via curl | |
# TO MANUALLY UPDATE FILE, VISIT PLAYWIRE URL BELOW AND CTRL+C, THEN CTRL+V INTO ads.txt | |
# run: curl https://config.playwire.com/dyn_ads/1025030/74482/ads.txt > ads.txt | |
#- name: Commit ads.txt using git commit | |
# run: | | |
# git config --global user.name 'DeathbyToast' | |
# git config --global user.email 'alex.gronbach@gmail.com' | |
# git add ads.txt | |
# git commit -m "Automated ads.txt update" | |
# git push origin | |
#- name: Create PR using gh pr create | |
# run: gh pr create --title "Automated ads.txt update" --body "Ensuring ads.txt is up to date" --base "gh-pages" --head "gh-pages" | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- run: echo "π This job's status is ${{ job.status }}." |