forked from Classiq/classiq-library
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (122 loc) · 3.54 KB
/
deployment-qmod.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: "Deployment - qmod"
on:
workflow_dispatch:
inputs:
deploy-mode:
description: "Deploy mode"
type: choice
required: true
default: staging
options:
- staging
- release_candidate
- production
workflow_call:
inputs:
deploy-mode:
description: "Deploy mode"
type: string
required: true
jobs:
get-config:
runs-on: ubuntu-24.04
outputs:
environment: ${{ steps.get-config.outputs.environment }}
qmod-bucket: ${{ steps.get-config.outputs.qmod-bucket }}
branch: ${{ steps.get-config.outputs.branch }}
steps:
- id: get-config
name: "Get Configuration from deploy-mode"
env:
INPUTS_BUILD_MODE: ${{ inputs.deploy-mode }}
run: |
set -ex
case "$INPUTS_BUILD_MODE" in
production)
ENVIRONMENT=prod
QMOD_BUCKET="qmod-library-prod"
BRANCH="main"
;;
release_candidate)
ENVIRONMENT=prod
QMOD_BUCKET="qmod-library-pre-release"
BRANCH="main"
;;
staging)
ENVIRONMENT=staging
QMOD_BUCKET="qmod-library-nightly"
BRANCH="dev"
;;
*)
echo unknown
exit 1
;;
esac
{
echo "environment=${ENVIRONMENT}"
echo "qmod-bucket=${QMOD_BUCKET}"
echo "branch=${BRANCH}"
} >>"$GITHUB_OUTPUT"
main:
needs: get-config
env:
QMOD_DIR: qmod
name: Deploy QMOD app
runs-on: ubuntu-24.04
environment: ${{ needs.get-config.outputs.environment }}
permissions:
id-token: write
contents: read
steps:
# We Checkout twice, once from main to get the latest actions, and second from dev to get QMODs
- name: Checkout actions
uses: actions/checkout@v4
with:
lfs: "false"
sparse-checkout: ".github"
sparse-checkout-cone-mode: false
- uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_ROLE }}
aws-region: "us-east-1"
mask-aws-account-id: true
- name: Checkout qmod
uses: actions/checkout@v4
with:
lfs: "false"
path: qmod
ref: ${{ needs.get-config.outputs.branch }}
- name: Join QMOD Metadata
run: |
python3 .github/scripts/join_qmod_metadata.py "$QMOD_DIR" "$QMOD_DIR"/qmod_metadata.json
- name: "Upload Qmod"
env:
QMOD_BUCKET: ${{ needs.get-config.outputs.qmod-bucket }}
run: |
set -e
aws s3 sync "$QMOD_DIR" "s3://${QMOD_BUCKET}/latest" \
--delete --exclude "*" --include "qmod_metadata.json" --include "*.qmod" --include "*.synthesis_options.json"
create_pr_for_next_deployment:
needs: main
name: Create PR for next deployment
runs-on: ubuntu-24.04
if: inputs.deploy-mode == 'production'
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: "false"
ref: dev
- name: Update release log
run: |
date --iso-8601=minutes >> .github/release_log.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
title: '[CI] Merge dev into main'
branch: dev
base: main