forked from alexandru-slobodcicov/liquibase-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add .github/workflows/dry-run-release.yml
- Loading branch information
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "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 |