Skip to content

Stable Release Step 2 - Validate PR #2

Stable Release Step 2 - Validate PR

Stable Release Step 2 - Validate PR #2

name: Stable Release Step 2 - Validate PR
on:
workflow_dispatch:
workflow_call:
jobs:
run-install-tests:
runs-on: ubuntu-22.04
steps:
- name: Call main workflow that calls all the distros
run: gh workflow run --repo FOGProject/fogproject-install-validation run_all_distros.yml
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_VALIDATION_REPO_TOKEN }}
check-all-tests-completed-successfully:
needs: run-install-tests
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.INSTALL_VALIDATION_REPO_TOKEN }}
steps:
- name: Wait a minute for the runs to start
run: sleep 60
- name: Get run IDs
run: |
run_id=$(gh run list --repo FOGProject/fogproject-install-validation --workflow run_all_distros.yml --json databaseId --limit 1 | jq -r '.[0].databaseId')
echo "RUN_ID=$run_id" >> $GITHUB_ENV
- name: Check if distro workflow passed or failed
run: |
run_status=""
while [[ $run_status != "success" && $run_status != "failure" ]]; do
sleep 15
run_status=$(gh run view --repo FOGProject/fogproject-install-validation ${{ env.RUN_ID }} --exit-status --json conclusion | jq -r '.conclusion')
done
if [[ $run_status == "failure" ]]; then
exit 1
fi
merge-after-all-tests-passed:
needs: check-all-tests-completed-successfully
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/stable'
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Merge The PR
run: |
echo 'Get the tag'
git fetch origin dev-branch
git checkout dev-branch
system_file="$(git rev-parse --show-toplevel)/packages/web/lib/fog/system.class.php"
tag=$(grep "define('FOG_VERSION'" $system_file | sed "s/.*FOG_VERSION', '\([^']*\)');/\1/")
git checkout stable
echo "merge the pull request bringing dev-branch into stable";
gh pr merge dev-branch --squash --subject "Stable Release - ${tag}";
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
close-pr-if-tests-fail:
needs: check-all-tests-completed-successfully
runs-on: ubuntu-22.04
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get PR number
run: |
pr_number=$(gh pr list --repo ${{ github.repository }} --json title,number | jq -r '.[] | select(.title | test("Stable Release PR for*"; "i")) | .number')
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
- name: Close PR
run: |
closure_message="Closing PR due to failure in tests"
gh pr close --comment "$closure_message" ${{ env.PR_NUMBER }}
- name: Announce error on Discord
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
content: "Hey @everyone, validation tests failed. PR closed"
title: Validation tests
status: ${{ needs.check-all-tests-completed-successfully.result }}
color: 0xff0000
call-tag-and-release-workflow:
needs: merge-after-all-tests-passed
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
ref: stable
- name: Run tag and release workflow
run: gh workflow run stable-releases-3_tag-and-release.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}