Dry run release #3
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
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: | ||
setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
dry_run_id: ${{ steps.get_run_id.outputs.dry_run_id }} | ||
dry_run_branch_name: ${{ steps.get_run_id.dry_run_branch_name }} | ||
steps: | ||
- name: Get run-tests.yml runId | ||
id: get_run_id | ||
run: | | ||
# Fetch the list of workflow runs | ||
response=$(curl -s \ | ||
-H "Authorization: token ${{ secrets.BOT_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/liquibase/liquibase/actions/workflows/run-tests.yml/runs?branch=master&status=success&per_page=1") | ||
# Extract the last successful run ID | ||
run_id=$(echo "$response" | jq -r '.workflow_runs[0].id') | ||
echo "dry_run_id=$run_id" >> $GITHUB_OUTPUT | ||
echo "dry_run_branch_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT | ||
dry-run-create-release: | ||
needs: [ setup ] | ||
uses: liquibase/liquibase/.github/workflows/create-release.yml@master | ||
with: | ||
version: "dry-run-${{ github.run_id }}" | ||
runId: ${{ needs.setup.outputs.dry_run_id }} | ||
standalone_zip: false | ||
dry_run: true | ||
secrets: inherit | ||
dry-run-get-draft-release: | ||
needs: [ setup, dry-run-create-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="vdry-run-${{ github.run_id }}" | ||
response=$(curl -s -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
"https://api.github.com/repos/liquibase/liquibase/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: | ||
Check failure on line 63 in .github/workflows/dry-run-release.yml GitHub Actions / Dry run releaseInvalid workflow file
|
||
needs: [ setup, dry-run-create-release, dry-run-get-draft-release ] | ||
uses: liquibase/liquibase/.github/workflows/release-published.yml@master | ||
with: | ||
tag: "vdry-run-${{ github.run_id }}" | ||
dry_run_release_id: ${{ needs.dry-run-get-draft-release.outputs.dry_run_release_id }} | ||
dry_run_zip_url: ${{ needs.dry-run-create-release.outputs.dry_run_zip_url }} | ||
dry_run_tar_gz_url: ${{ needs.dry-run-create-release.outputs.dry_run_tar_gz_url }} | ||
dry_run: true | ||
dry_run_branch_name: ${{ needs.dry-run-create-release.outputs.dry_run_branch_name }} | ||
secrets: inherit | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
if: always() | ||
needs: [ setup, 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/vdry-run-${{ github.run_id }} | ||
echo "Remote tag vdry-run-${{ github.run_id }} 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: [ setup, dry-run-create-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 |