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 new file mode 100644 index 0000000..c896504 --- /dev/null +++ b/.github/workflows/theme-release.yml @@ -0,0 +1,55 @@ +name: Slack notification for new theme release + +on: + workflow_run: + workflows: + - "documentation preview" + types: [completed] + +permissions: + contents: read + +jobs: + release-notification: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.event == 'release' }} + 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 }}