enh: github actions to only notify Discord if files have actually changed

This commit is contained in:
Ben Allfree 2023-10-04 08:50:48 -07:00
parent 285e7ea8d2
commit b3cfceb999

View File

@ -22,8 +22,23 @@ jobs:
yarn lint
yarn build
- name: Get changed www files
id: changed-www-files
uses: tj-actions/changed-files@v35
with:
files: |
packages/www/**
- name: Get changed www files
id: changed-dashboard-files
uses: tj-actions/changed-files@v35
with:
files: |
packages/dashboard/**
- name: Publish www to Cloudflare Pages
uses: cloudflare/pages-action@v1
if: steps.changed-www-files.outputs.any_changed == 'true'
id: www_deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
@ -36,6 +51,7 @@ jobs:
- name: Publish dashboard to Cloudflare Pages
uses: cloudflare/pages-action@v1
if: steps.changed-dashboard-files.outputs.any_changed == 'true'
id: dashboard_deploy
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
@ -49,18 +65,34 @@ jobs:
- name: Expose git commit data
uses: rlespinasse/git-commit-data-action@v1
- name: Discord feature branch notification
if: github.ref_name != 'master'
- name: Discord feature branch notification for dashboard
if: github.ref_name != 'master' && steps.changed-dashboard-files.outputs.any_changed == 'true'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**PREVIEW** ${{ steps.www_deploy.outputs.url }} and ${{ steps.dashboard_deploy.outputs.url }} were generated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}) with memo `${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}`'
args: '**PREVIEW** ${{ steps.dashboard_deploy.outputs.url }} was generated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}) with memo `${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}`'
- name: Discord live branch notification
if: github.ref_name == 'master'
- name: Discord feature branch notification for www
if: github.ref_name != 'master' && steps.changed-www-files.outputs.any_changed == 'true'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**LIVE** https://pockethost.io ([permalink](${{ steps.www_deploy.outputs.url }})) and https://app.pockethost.io ([permalink](${{ steps.dashboard_deploy.outputs.url }})) were updated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}): ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}'
args: '**PREVIEW** ${{ steps.www_deploy.outputs.url }} was generated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}) with memo `${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}`'
- name: Discord live branch notification for dashboard
if: github.ref_name == 'master' && steps.changed-dashboard-files.outputs.any_changed == 'true'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**LIVE** https://pockethost.io ([permalink](${{ steps.www_deploy.outputs.url }})) was updated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}): ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}'
- name: Discord live branch notification for www
if: github.ref_name == 'master' && steps.changed-www-files.outputs.any_changed == 'true'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: '**LIVE** https://app.pockethost.io ([permalink](${{ steps.dashboard_deploy.outputs.url }})) was updated by ${{ github.actor }} in [${{ env.GIT_COMMIT_SHORT_SHA }}](https://github.com/${{ github.repository}}/commit/${{ github.sha }}) on [${{ github.repository}}#${{ github.ref_name }}](https://github.com/${{ github.repository}}/tree/${{ github.ref_name }}): ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}'