|
3 | 3 | # These variables will be populated from environment
|
4 | 4 | ##################################################################################
|
5 | 5 | env:
|
6 |
| - DEPLOYMENT_NAME_DEFAULT: debug |
7 | 6 | DEPLOYMENT_REPO: ${{vars.DEPLOYMENT_REPO}}
|
8 |
| - DEPLOYMENT_PRIVATE_KEY: ${{secrets.DEPLOYMENT_PRIVATE_KEY}} |
9 |
| - FIREBASE_CONFIG_TS: ${{secrets.FIREBASE_CONFIG_TS}} |
| 7 | + DEPLOYMENT_NAME: ${{vars.DEPLOYMENT_NAME}} |
| 8 | + DEPLOYMENT_REPO_PRIVATE_KEY: ${{secrets.DEPLOYMENT_PRIVATE_KEY}} |
10 | 9 |
|
11 | 10 | ##################################################################################
|
12 | 11 | # Main Code
|
|
25 | 24 | # Optional variables to configure from parent workflow via workflow_call
|
26 | 25 | #############################################################################
|
27 | 26 | inputs:
|
| 27 | + deployment-env: |
| 28 | + description: Name of environment to load deployment variables from |
| 29 | + type: string |
| 30 | + required: true |
| 31 | + default: debug |
28 | 32 | build-flags:
|
29 | 33 | description: Additional flags to pass to build command (e.g. base-href)
|
30 | 34 | type: string
|
|
33 | 37 | description: Name of branch to build (defaults to event trigger sha)
|
34 | 38 | type: string
|
35 | 39 | default: ""
|
36 |
| - deployment: |
37 |
| - description: | |
38 |
| - Target deployment name. If branch name provided will take suffix (`prod/my_deployment` -> `my_deployment`). |
39 |
| - Will load variables from named deployment environment |
40 |
| - type: string |
41 |
| - default: "" |
42 | 40 | include-tests:
|
43 | 41 | description: "Specify whether to include running workspace lint and test before build"
|
44 | 42 | type: boolean
|
|
64 | 62 | value: ${{ jobs.configure_build.outputs.GIT_SHA }}
|
65 | 63 |
|
66 | 64 | jobs:
|
67 |
| - ############################################################################# |
68 |
| - # configure Build |
69 |
| - # Deployment-specific variables are loaded from deployment name environment contexts |
70 |
| - # stored on github actions. |
71 |
| - # Determine which set of environment variables to load, depending on passed inputs, |
72 |
| - # target branch names or default fallback |
73 |
| - # Populate variables to use as inputs in next build job |
74 |
| - # Pattern found in this question: https://github.com/actions/runner/issues/998#issue-817330769 |
75 |
| - # Outputs here will also be made available to parent workflows via workflow_call outputs |
76 |
| - ############################################################################# |
| 65 | + |
77 | 66 | configure_build:
|
| 67 | + environment: ${{inputs.deployment-env}} |
78 | 68 | outputs:
|
79 | 69 | DEPLOYMENT_NAME: ${{ steps.populate.outputs.DEPLOYMENT_NAME }}
|
80 | 70 | GIT_SHA: ${{ steps.populate.outputs.GIT_SHA }}
|
81 | 71 | runs-on: ubuntu-latest
|
82 | 72 | steps:
|
83 |
| - - uses: actions/checkout@v3 |
| 73 | + - uses: actions/checkout@v4 |
84 | 74 | with:
|
85 | 75 | ref: ${{inputs.branch}}
|
86 | 76 |
|
87 |
| - - name: Set named input environment |
88 |
| - if: ${{ inputs.environment }} |
89 |
| - run: | |
90 |
| - echo "DEPLOYMENT_NAME=${{inputs.environment}}" >> $GITHUB_ENV; |
91 |
| - shell: bash |
92 |
| - |
93 |
| - - name: Set environment from target |
94 |
| - if: ${{inputs.deployment && inputs.deployment != 'master' && inputs.deployment!='refs/heads/master'}} |
95 |
| - run: | |
96 |
| - echo "DEPLOYMENT_NAME=$(echo ${{inputs.deployment}} | sed 's/.*\///')" >> $GITHUB_ENV; |
97 |
| - shell: bash |
98 |
| - |
99 |
| - - name: Set default environment |
100 |
| - if: ${{ !env.DEPLOYMENT_NAME }} |
101 |
| - run: | |
102 |
| - echo "DEPLOYMENT_NAME=$DEPLOYMENT_NAME_DEFAULT" >> $GITHUB_ENV; |
103 |
| - shell: bash |
104 |
| - |
105 | 77 | # Output determined environment name alongside git SHA (for use in error logging)
|
106 | 78 | - name: Populate Outputs
|
107 | 79 | id: populate
|
|
116 | 88 | environment: ${{needs.configure_build.outputs.DEPLOYMENT_NAME}}
|
117 | 89 | env:
|
118 | 90 | GIT_SHA: ${{ needs.configure_build.outputs.GIT_SHA }}
|
119 |
| - DEPLOYMENT_NAME: ${{ needs.configure_build.outputs.DEPLOYMENT_NAME }} |
120 | 91 | steps:
|
121 |
| - - uses: actions/checkout@v3 |
| 92 | + - uses: actions/checkout@v4 |
122 | 93 | with:
|
123 | 94 | lfs: ${{inputs.lfs}}
|
124 | 95 | ref: ${{inputs.branch}}
|
@@ -161,18 +132,17 @@ jobs:
|
161 | 132 | run: echo "export const GIT_SHA = \"$GIT_SHA\";" > src/environments/sha.ts
|
162 | 133 |
|
163 | 134 | - name: Import remote deployment
|
164 |
| - if: ${{env.DEPLOYMENT_REPO}} |
165 |
| - uses: actions/checkout@v3 |
| 135 | + uses: actions/checkout@v4 |
166 | 136 | with:
|
167 | 137 | repository: ${{env.DEPLOYMENT_REPO}}
|
168 | 138 | lfs: ${{inputs.lfs}}
|
169 | 139 | path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}"
|
170 | 140 | # TODO - add support for specific branch/release
|
171 | 141 |
|
172 | 142 | - name: Set deployment private key
|
173 |
| - if: ${{env.DEPLOYMENT_PRIVATE_KEY}} |
| 143 | + if: ${{env.DEPLOYMENT_REPO_PRIVATE_KEY}} |
174 | 144 | run:
|
175 |
| - echo $DEPLOYMENT_PRIVATE_KEY > .idems_app/deployments/$DEPLOYMENT_NAME/encrypted/private.key |
| 145 | + echo $DEPLOYMENT_REPO_PRIVATE_KEY > .idems_app/deployments/$DEPLOYMENT_NAME/encrypted/private.key |
176 | 146 |
|
177 | 147 | - name: Set deployment
|
178 | 148 | run: yarn workflow deployment set ${{env.DEPLOYMENT_NAME}}
|
|
0 commit comments