Skip to content

Commit

Permalink
Add .github/workflows/dry-run-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
liquibot committed Sep 12, 2024
1 parent 21f0882 commit f3054c7
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/dry-run-release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- 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

0 comments on commit f3054c7

Please sign in to comment.