From 12b9db426c975f4d5356617b445bd4aa5f9c76e6 Mon Sep 17 00:00:00 2001 From: liquibot <64099989+liquibot@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:08:17 -0500 Subject: [PATCH] Add .github/workflows/dry-run-release.yml --- .github/workflows/dry-run-release.yml | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/dry-run-release.yml diff --git a/.github/workflows/dry-run-release.yml b/.github/workflows/dry-run-release.yml new file mode 100644 index 0000000..9cbfada --- /dev/null +++ b/.github/workflows/dry-run-release.yml @@ -0,0 +1,92 @@ +name: Dry run release + +on: + workflow_dispatch: # Trigger on demand + schedule: # Trigger weekly all Wednesdays at midnight UTC + # Trigger weekly on Wednesday at midnight Austin time (Standard Time) + - cron: "0 6 * * 3" + +jobs: + + dry-run-attach-artifact-to-release: + uses: liquibase/build-logic/.github/workflows/extension-attach-artifact-release.yml@main + secrets: inherit + with: + dry_run: true + dry_run_version: "0.0.${{ github.run_number }}" + + dry-run-get-draft-release: + needs: dry-run-attach-artifact-to-release + runs-on: ubuntu-latest + outputs: + dry_run_release_id: ${{ steps.get_draft_release_id.outputs.release_id }} + steps: + - name: Get Draft Release ID + id: get_draft_release_id + run: | + release_name="v0.0.${{ github.run_number }}" + response=$(curl -s -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/releases") + draft_release=$(echo "$response" | jq -r --arg name "$release_name" '.[] | select(.name == $name and .draft == true)') + if [ -z "$draft_release" ]; then + echo "No draft release found with the name '$release_name'" + exit 1 + else + echo "$draft_release" | jq . + release_id=$(echo "$draft_release" | jq -r '.id') + echo "release_id=$release_id" >> $GITHUB_OUTPUT + fi + + dry-run-release-published: + needs: dry-run-get-draft-release + uses: liquibase/build-logic/.github/workflows/extension-release-published.yml@main + secrets: inherit + with: + dry_run: true + dry_run_version: "0.0.${{ github.run_number }}" + dry_run_release_id: ${{ needs.dry-run-get-draft-release.outputs.dry_run_release_id }} + deployToMavenCentral: false + + cleanup: + runs-on: ubuntu-latest + if: always() + needs: [ dry-run-get-draft-release, dry-run-release-published ] + steps: + - name: Checkout liquibase + uses: actions/checkout@v4 + + - name: Set up Git + run: | + git config user.name "liquibot" + git config user.email "liquibot@liquibase.org" + + - name: Delete liquibase dry-run tag + if: always() + run: | + git push origin --delete refs/tags/v0.0.${{ github.run_number }} + echo "Remote tag v0.0.${{ github.run_number }} deleted" + + - name: Delete the dry-run draft release + if: always() + run: | + curl -X DELETE -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${{ github.repository }}/releases/${{ needs.dry-run-get-draft-release.outputs.dry_run_release_id }}" + + notify: + if: failure() + runs-on: ubuntu-latest + needs: [ dry-run-attach-artifact-to-release, dry-run-get-draft-release, dry-run-release-published, cleanup ] + steps: + - name: Notify Slack on Build Failure + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: failure + SLACK_MESSAGE: "View details on GitHub Actions: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} <@U040C8J8143> <@U04P39MS2SW> <@UHHJ6UAEQ> <@U042HRTL4DT>" # Jandro, Sailee, Jake, Filipe + SLACK_TITLE: "❌ ${{ github.repository }} ❌ Build failed on branch ${{ github.ref }} for commit ${{ github.sha }} in repository ${{github.repository}}" + SLACK_USERNAME: liquibot + SLACK_WEBHOOK: ${{ secrets.DRY_RUN_RELEASE_SLACK_WEBHOOK }} + SLACK_ICON_EMOJI: ":robot_face:" + SLACK_FOOTER: "${{ github.repository }}" + SLACK_LINK_NAMES: true \ No newline at end of file