From 952e6e7c5d6ed5b39a6eb0a970c02773c7c6a022 Mon Sep 17 00:00:00 2001 From: ccamel Date: Mon, 14 Oct 2024 19:22:28 +0200 Subject: [PATCH] ci(workflow): enable manual trigger with specific tag input --- .github/workflows/notify-release.yml | 56 +++++++++++++++++++--------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/.github/workflows/notify-release.yml b/.github/workflows/notify-release.yml index 3da2e219..89aed8fd 100644 --- a/.github/workflows/notify-release.yml +++ b/.github/workflows/notify-release.yml @@ -4,39 +4,59 @@ on: release: types: [published] + workflow_dispatch: + inputs: + tag: + description: "Release tag (leave empty for last one)" jobs: + set-env: + runs-on: ubuntu-22.04 + outputs: + tag: ${{ steps.set-env.outputs.tag }} + repo_name: ${{ steps.set-env.outputs.repo_name }} + steps: + - name: Expose tag and repo_name + id: set-env + run: | + if [ -n "$INPUT_TAG" ]; then + TAG="$INPUT_TAG" + else + TAG=$(gh release view --json tagName -q '.tagName') + fi + echo "tag=$TAG" >> $GITHUB_OUTPUT + + REPO_NAME=${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/} + echo "repo_name=$REPO_NAME" >> $GITHUB_OUTPUT + env: + INPUT_TAG: ${{ github.event.inputs.tag }} + notify-github-discussion: runs-on: ubuntu-22.04 + needs: set-env steps: - name: Check out repository uses: actions/checkout@v4 - - name: Set ENV variables - run: | - echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV - - name: Extract changelog for tag run: | { echo 'CHANGELOG<> "$GITHUB_ENV" - env: - TAG: ${{ github.event.release.tag_name }} - name: Create an announcement discussion for release uses: abirismyname/create-discussion@v1.2.0 with: - title: 🎉 ${{ env.REPO_NAME }} ${{ github.event.release.tag_name }} released! + title: 🎉 ${{ needs.set-env.outputs.repo_name }} ${{ needs.set-env.outputs.tag }} released! body: | - [${{ github.repository }}](https://github.com/${{ github.repository }}) ${{ github.event.release.tag_name }} has been released! + [${{ github.repository }}](https://github.com/${{ github.repository }}) ${{ needs.set-env.outputs.tag }} has been released! ${{ env.CHANGELOG }} ## Resources - 📄 Changelog: + 📄 Changelog: 🛠️ Official repo: 💬 Join us on Discord: <${{ env.DISCORD_URL }}> 🐦 Follow us on Twitter: <${{ env.TWITTER_URL }}> @@ -44,10 +64,10 @@ jobs: category-id: ${{ env.CATEGORY_ID }} env: GH_TOKEN: ${{ secrets.OPS_TOKEN }} - DISCORD_URL: "https://discord.gg/axone" - TWITTER_URL: "https://twitter.com/axonexyz" - REPOSITORY_ID: "R_kgDOLsWt6A" - CATEGORY_ID: "DIC_kwDOLsWt6M4CemGO" + DISCORD_URL: ${{ vars.DISCORD_URL }} + TWITTER_URL: ${{ vars.TWITTER_URL }} + REPOSITORY_ID: ${{ vars.DISCUSSIONS_REPOSITORY_ID }} + CATEGORY_ID: ${{ vars.DISCUSSIONS_CATEGORY_ID }} update-docs: runs-on: ubuntu-22.04 @@ -62,7 +82,7 @@ jobs: { "ref": "main", "inputs": { - "version": "${{ github.event.release.tag_name }}", + "version": "${{ needs.set-env.outputs.tag }}", "repository": "${{github.repository}}", "section": "modules", "docs_directory": "docs/proto/*" @@ -79,7 +99,7 @@ jobs: { "ref": "main", "inputs": { - "version": "${{ github.event.release.tag_name }}", + "version": "${{ needs.set-env.outputs.tag }}", "repository": "${{github.repository}}", "section": "commands", "docs_directory": "docs/command/*" @@ -96,7 +116,7 @@ jobs: { "ref": "main", "inputs": { - "version": "${{ github.event.release.tag_name }}", + "version": "${{ needs.set-env.outputs.tag }}", "repository": "${{github.repository}}", "section": "predicates", "docs_directory": "docs/predicate/*" @@ -116,6 +136,6 @@ jobs: { "ref": "main", "inputs": { - "axonedVersion": "${{ github.event.release.tag_name }}" + "axonedVersion": "${{ needs.set-env.outputs.tag }}" } }