From 38e642b1b19cbb37e877d928f8303510feaace9b Mon Sep 17 00:00:00 2001 From: Fred Adeniyi Date: Wed, 23 Jul 2025 16:07:14 +0800 Subject: [PATCH 1/2] feat: Enhance CI/CD workflow with version tagging and Discord notifications --- .github/workflows/deploy_note_app.yml | 57 ++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_note_app.yml b/.github/workflows/deploy_note_app.yml index 48b928e..3eaa518 100644 --- a/.github/workflows/deploy_note_app.yml +++ b/.github/workflows/deploy_note_app.yml @@ -134,9 +134,14 @@ jobs: contents: 'write' # Required to push new tags # Skip tagging if the commit message contains #skip for push events on the target branch if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '#skip') }} + outputs: + tag: ${{ steps.tag_version.outputs.tag }} + changelog: ${{ steps.tag_version.outputs.changelog }} steps: - name: Checkout repository uses: actions/checkout@v4.1.7 + with: + fetch-depth: 0 # Required for changelog generation - name: Bump version and push tag id: tag_version @@ -147,4 +152,54 @@ jobs: DEFAULT_BUMP: patch - name: Log new tag - run: echo "New tag is ${{ steps.tag_version.outputs.tag }}" \ No newline at end of file + run: echo "New tag is ${{ steps.tag_version.outputs.tag }}" + + create_release: + name: Create GitHub Release + needs: [tag_release] + runs-on: ubuntu-24.04 + permissions: + contents: 'write' # Required to create a release + steps: + - name: Create GitHub Release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ needs.tag_release.outputs.tag }} + release_name: Release ${{ needs.tag_release.outputs.tag }} + body: ${{ needs.tag_release.outputs.changelog }} + draft: false + prerelease: false + + notify: + name: Discord Notification + needs: [test, create_release] + runs-on: ubuntu-24.04 + if: always() # This is key - it runs even if previous jobs fail + steps: + - name: Determine Status + id: status_check + run: | + if [[ "${{ needs.test.result }}" == "failure" || "${{ needs.create_release.result }}" == "failure" ]]; then + echo "status=failure" >> $GITHUB_OUTPUT + echo "color=15548997" >> $GITHUB_OUTPUT + echo "status_text=Failed" >> $GITHUB_OUTPUT + else + echo "status=success" >> $GITHUB_OUTPUT + echo "color=5763719" >> $GITHUB_OUTPUT + echo "status_text=Success" >> $GITHUB_OUTPUT + fi + + - name: Send Discord notification + uses: sarisia/actions-status-discord@v1.14.0 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ steps.status_check.outputs.status }} + title: "Pipeline for `${{ github.repository }}`" + description: | + Workflow **${{ github.workflow }}** has finished with status: **${{ steps.status_check.outputs.status_text }}** + Commit: `${{ github.sha }}` by `${{ github.actor }}` + View Workflow Run + color: ${{ steps.status_check.outputs.color }} + username: "GitHub Actions" \ No newline at end of file From 3b40e1ac23d4cf9bf50d21ddc13dfd5286149299 Mon Sep 17 00:00:00 2001 From: Fred Adeniyi Date: Wed, 23 Jul 2025 17:48:52 +0800 Subject: [PATCH 2/2] fix: Update Discord notification action to use the latest version --- .github/workflows/deploy_note_app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy_note_app.yml b/.github/workflows/deploy_note_app.yml index 3eaa518..f2ba0f2 100644 --- a/.github/workflows/deploy_note_app.yml +++ b/.github/workflows/deploy_note_app.yml @@ -192,7 +192,7 @@ jobs: fi - name: Send Discord notification - uses: sarisia/actions-status-discord@v1.14.0 + uses: sarisia/actions-status-discord@v1 with: webhook: ${{ secrets.DISCORD_WEBHOOK }} status: ${{ steps.status_check.outputs.status }}