-
Notifications
You must be signed in to change notification settings - Fork 2
78 lines (77 loc) · 3.41 KB
/
promote-release-candidate.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
name: Promote Release Candidate on SemVer Tag Push
on:
push:
tags:
- 'v*' # Regex pattern to match semantic version strings that begin with a lowercase v followed by any number of digits and dots: v1.0.0, v1.0.0-alpha, etc
jobs:
promote-release-candidate-to-prod:
runs-on: ubuntu-latest
env:
JF_ENV_1: ${{ secrets.JF_ENV_1 }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
JF_BASE_URL: ${{ vars.JF_BASE_URL }}
RELEASE_BUNDLE_SIGNING_KEY: ${{ secrets.RELEASE_BUNDLE_SIGNING_KEY }}
JFROG_BUILD_STATUS: PASS
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v3
with:
version: latest
- name: Fetch the latest Release Bundle
id: fetch_release_bundle
run: |
{
echo 'LATEST_RELEASE_BUNDLE_VERSION<<EOF'
curl --request GET \
--url "$JF_BASE_URL/lifecycle/api/v2/release_bundle/records/phoenix-project-release-bundle?order_by=created&limit=1" \
--header "Authorization: Bearer $JF_ACCESS_TOKEN" | jq -r '.release_bundles[0].release_bundle_version'
echo EOF
} >> $GITHUB_OUTPUT
- name: Validate Release Bundle Response
id: validate_release_bundle_response
run: |
echo ${{ steps.fetch_release_bundle.outputs.LATEST_RELEASE_BUNDLE_VERSION }}
- name: Promote Release Bundle
id: promote_release_bundle
env:
RELEASE_BUNDLE_VERSION: ${{ steps.fetch_release_bundle.outputs.LATEST_RELEASE_BUNDLE_VERSION }}
run: |
PROMOTE_RESULT=$(curl --request "POST" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $JF_ACCESS_TOKEN" \
--header "X-JFrog-Signing-Key-Name: $RELEASE_BUNDLE_SIGNING_KEY" \
--data '{"environment":"PROD","included_repository_keys":["phoenix-maven-prod-local"],"overwrite_existing_artifacts":false}' \
--url "https://tomjfrog.jfrog.io/lifecycle/api/v2/promotion/records/phoenix-project-release-bundle/$RELEASE_BUNDLE_VERSION")
echo PROMOTE_RESULT=$PROMOTE_RESULT >> $GITHUB_OUTPUT
- name: Validate Promotion
id: validate_promotion
run: |
echo "Promotion to Prod Result: " ${{ steps.promote_release_bundle.outputs.PROMOTE_RESULT }}
- name: Distribute Release Bundle to Edge Nodes
id: distribute_release_bundle
env:
RELEASE_BUNDLE_VERSION: ${{ steps.fetch_release_bundle.outputs.LATEST_RELEASE_BUNDLE_VERSION }}
run: |
DISTRIBUTION_RESULT=$(curl --request "POST" \
--url "$JF_BASE_URL/lifecycle/api/v2/distribution/distribute/phoenix-project-release-bundle/$RELEASE_BUNDLE_VERSION" \
--header "Authorization: Bearer $JF_ACCESS_TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"dry_run": false,
"auto_create_missing_repositories": "true",
"distribution_rules": [
{
"site_name": "tomjfrogedge1"
},
{
"site_name": "tomjfrogedge2"
}
]
}')
echo DISTRIBUTION_RESULT=$DISTRIBUTION_RESULT >> $GITHUB_OUTPUT
- name: Validate Distribution
id: validate_distribution
run: |
echo "Distribution Result: ${{ steps.distribute_release_bundle.outputs.DISTRIBUTION_RESULT }}"