Regularly Scheduled GitHub Actions π Diff Workflow #37
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: | |
- cron: '39 9 * * *' | |
- cron: '39 9 * * *' | |
jobs: | |
Diff-ads-txt: | |
runs-on: ubuntu-latest | |
outputs: | |
output1: ${{ 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 | |
#continue-on-error: true | |
id: diff-adstxt-files | |
# https://trstringer.com/github-actions-multiline-strings/ | |
run: | | |
DIFF_OUT=$(cat << EOF | |
`diff --suppress-common-lines <(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 --suppress-common-lines <(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 }}." #due to continue-on-error=true." | |
Diff-status: | |
if: failure() | |
needs: Diff-ads-txt | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- run: echo "The diff failed with:" | |
- run: echo "${{needs.Diff-ads-txt.outputs.output1}}" | |
- run: echo "Proceeding to replace ads.txt..." | |
# https://stackoverflow.com/a/58393457 | |
- uses: actions/checkout@v3 | |
- name: Get Updated ads.txt file | |
run: curl https://config.playwire.com/dyn_ads/1025030/74482/ads.txt > ads.txt | |
- name: Commit ads.txt and submit PR | |
run: | | |
echo "Creating PR for ads.txt in gh-pages" | |
git config --global user.name 'DeathbyToast' | |
git config --global user.email 'alex.gronbach@gmail.com' | |
git commit -am "Automated ads.txt update" | |
gh pr create --title "Automated ads.txt update" --base "gh-pages" | |
- run: echo "π This job's status is ${{ job.status }}." |