From 8244882cc6e4c3e905460e472a0cf4e32e4f7238 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 14 May 2025 11:11:26 -0700 Subject: [PATCH 1/2] Action: Notifications for published release --- .github/workflows/theme-release.yml | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/theme-release.yml diff --git a/.github/workflows/theme-release.yml b/.github/workflows/theme-release.yml new file mode 100644 index 0000000..0d15112 --- /dev/null +++ b/.github/workflows/theme-release.yml @@ -0,0 +1,53 @@ +name: Slack notification for new theme release + +on: + release: + types: + - published + +permissions: + contents: read + +jobs: + release-notification: + runs-on: ubuntu-latest + permissions: + contents: read + actions: read # for 8398a7/action-slack + checks: read + steps: + - name: Send notification + uses: 8398a7/action-slack@1750b5085f3ec60384090fb7c52965ef822e869e # v3.18.0 + with: + status: custom + custom_payload: | + { + username: 'Github', + mention: 'channel', + attachments: [{ + title: `New theme release - ${{ github.event.release.name }}`, + color: '#009223', + fields: [{ + title: 'Preview', + value: `SOME PREVIEW LINK`, + short: false + }, + { + title: 'Tag', + value: `${{ github.event.release.tag_name }}`, + short: true + }, + { + title: 'Author', + value: `${{ github.event.release.author.login }}`, + short: true + }, + { + title: 'URL', + value: `${{ github.event.release.html_url }}`, + short: true + }] + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} From a572ab7996ef50da1b84e457a78901af22ad6525 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 14 May 2025 13:22:07 -0700 Subject: [PATCH 2/2] Action: Add workflow for automated preview deployments on latest --- .github/workflows/previews.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/theme-release.yml | 8 +++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/previews.yml diff --git a/.github/workflows/previews.yml b/.github/workflows/previews.yml new file mode 100644 index 0000000..72be799 --- /dev/null +++ b/.github/workflows/previews.yml @@ -0,0 +1,29 @@ +name: documentation preview + +on: + release: + types: + - published + pull_request: + branches: + - "*" + +jobs: + build-documentation: + runs-on: ubuntu-latest + steps: + - name: Trigger `Build and deploy` workflow in `documentation` repo + run: | + repo_owner="nginx" + repo_name="documentation" + event_type="trigger-preview-build" + environment="preview" + theme_version="${{ github.head_ref || '' }}" # Will either be the branch name if triggered from pull request, or empty string (aka latest) if triggered from release + + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$repo_owner/$repo_name/dispatches \ + -d "{\"event_type\": \"$event_type\", \"client_payload\": {\"environment\": \"$environment\", \"hugo_theme_override\": \"$theme_version\"}}" diff --git a/.github/workflows/theme-release.yml b/.github/workflows/theme-release.yml index 0d15112..c896504 100644 --- a/.github/workflows/theme-release.yml +++ b/.github/workflows/theme-release.yml @@ -1,9 +1,10 @@ name: Slack notification for new theme release on: - release: - types: - - published + workflow_run: + workflows: + - "documentation preview" + types: [completed] permissions: contents: read @@ -11,6 +12,7 @@ permissions: jobs: release-notification: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.event == 'release' }} permissions: contents: read actions: read # for 8398a7/action-slack