Skip to content

Commit 8574cf9

Browse files
authored
[SD-325] GHA for Tide Release (#62)
* config script * config script * config script * oncall * oncall * oncall * oncall * oncall * filepath * filepath * test * test * test * test * test * test * test * test * test * test * test * test * push uat * push uat * test * test * test * test * test * test * create PR GHA
1 parent 3d5e2bf commit 8574cf9

File tree

3 files changed

+118
-31
lines changed

3 files changed

+118
-31
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Create Pull Request
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch_name:
7+
description: "Branch name to create PR from"
8+
required: true
9+
type: string
10+
PR_message:
11+
description: "PR Message"
12+
required: false
13+
default: Automated PR generated using GHA
14+
type: string
15+
16+
jobs:
17+
create_pull_request:
18+
name: Create Pull Request
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v4
24+
25+
- name: Create Pull Request
26+
run: |
27+
gh pr create \
28+
--title "Automated tide pull request for release {{ release }}" \
29+
--body "${{ inputs.PR_message }}" \
30+
--base develop \
31+
--head ${{ inputs.branch_name }} \
32+
--repo ${{ github.repository }}
Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
name: force_push_to_uat
22

3-
on:
3+
on:
44
workflow_call:
5+
inputs:
6+
branch_name:
7+
description: "Branch name to push changes to (e.g., release/SCFA-1234)"
8+
required: true
9+
type: string
510

611
jobs:
712
force_push_to_uat:
8-
name: force_push_to_uat
9-
if: startsWith(github.event.branches[0].name, 'release/')
13+
name: Force Push Branch to UAT
1014
runs-on: ubuntu-latest
15+
1116
steps:
1217
- name: Checkout code
1318
uses: actions/checkout@v4
14-
- name: Output caller branch
15-
run: echo ${{ github.event.branches[0].name }}
16-
- name: Output tested commit
17-
run: echo ${{ github.event.branches[0].commit.sha }}
18-
- name: Determine status state
19-
run: |
20-
output=$(curl -L \
21-
-H "Accept: application/vnd.github+json" \
22-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
23-
-H "X-GitHub-Api-Version: 2022-11-28" \
24-
https://api.github.com/repos/${{ github.repository }}/commits/${{ github.event.branches[0].commit.sha }}/status)
19+
with:
20+
fetch-depth: 0 # Fetch full branch history
2521

26-
api_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "api") | .state')
27-
e2e_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "e2e_be") | .state')
28-
build_status=$(echo "$output" | jq -r '.statuses[] | select(.context == "tide_build") | .state')
22+
- name: Fetch and Pull Latest Changes
23+
run: |
24+
git fetch origin "${{ inputs.branch_name }}"
25+
git checkout "${{ inputs.branch_name }}"
26+
git pull origin "${{ inputs.branch_name }}" # Ensure latest commits are present
2927
30-
echo "API test status is $api_status"
31-
echo "E2E test status is $e2e_status"
32-
echo "Build status is $build_status"
28+
- name: Log Branch State
29+
run: |
30+
echo "Branch state before force-push:"
31+
git log --oneline -5
3332
34-
if [[ $api_status == "success" && $e2e_status == "failure" && $build_status == "failure" ]]; then
35-
echo "==> All checks passed, deploying to UAT."
36-
exit 0
37-
else
38-
echo "==> Checks pending or failed, holding."
39-
exit 1
40-
fi
41-
- name: Force push
33+
- name: Force Push to UAT
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4236
run: |
43-
cd ${GITHUB_WORKSPACE}
44-
chmod +x .circleci/force-push-to-uat.sh
45-
.circleci/force-push-to-uat.sh
37+
git push origin "${{ inputs.branch_name }}:uat" --force
38+
39+
- name: Notify Completion
40+
if: success()
41+
run: echo "Branch ${{ inputs.branch_name }} has been force pushed to UAT."
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: export_config
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch_name:
7+
description: "Branch name to export config and push changes (e.g., release/SCFA-1234)"
8+
required: true
9+
type: string
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
14+
jobs:
15+
export_config:
16+
name: Export Config and Push to Branch
17+
runs-on: biggy
18+
container:
19+
image: ghcr.io/dpc-sdp/bay/ci-builder:5.x
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
fetch-tags: true
27+
28+
- name: Log into registry ghcr.io
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Uncomment database snapshot environment variable
36+
run: |
37+
sed -i 's|# DB_IMAGE_SNAPSHOT|DB_IMAGE_SNAPSHOT|' .env
38+
39+
- name: Configure Git
40+
run: |
41+
git config --global user.email "${{ secrets.DEPLOY_USER_EMAIL }}" && git config --global user.name "${{ secrets.DEPLOY_USER_NAME }}"
42+
43+
- name: Copy repo
44+
run: |
45+
chown -R $(id -u):$(id -g) $PWD
46+
cp -R ${GITHUB_WORKSPACE} /app
47+
48+
- name: Run export script
49+
run: |
50+
cd /app
51+
scripts/export-config-push-uat.sh "${{ inputs.branch_name }}"
52+
env:
53+
DEPLOY_USER_EMAIL: ${{ secrets.DEPLOY_USER_EMAIL }}
54+
DEPLOY_USER_NAME: ${{ secrets.DEPLOY_USER_NAME }}
55+
56+
- name: Notify completion
57+
if: success()
58+
run: |
59+
echo "Export config completed and pushed to branch ${{ inputs.branch_name }}."

0 commit comments

Comments
 (0)