-
Notifications
You must be signed in to change notification settings - Fork 227
112 lines (89 loc) · 3.5 KB
/
stable-releases-2_test-validity.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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 }}