1515env :
1616 REGISTRY : ghcr.io
1717 IMAGE_NAME : ${{ github.repository }}
18- PYTHON_VERSION : ' 3.10 '
19- POETRY_VERSION : ' 1.8.5 '
18+ PYTHON_VERSION : ' 3.12 '
19+ POETRY_VERSION : ' 2.3.2 '
2020 TERRAFORM_VERSION : ' 1.5.3'
2121
2222jobs :
@@ -29,19 +29,26 @@ jobs:
2929 packages : write
3030 id-token : write
3131
32+ outputs :
33+ new_version : ${{ steps.build-outputs.outputs.new_version }}
34+ pyproject_name : ${{ steps.build-outputs.outputs.pyproject_name }}
35+ target_env_uppercase : ${{ steps.build-outputs.outputs.target_env_uppercase }}
36+ target_env_lowercase : ${{ steps.build-outputs.outputs.target_env_lowercase }}
37+ source : ${{ steps.build-outputs.outputs.source }}
38+
3239 steps :
33- - uses : actions/checkout@v4
40+ - uses : actions/checkout@v6
3441 with :
3542 fetch-depth : 0 # Needed for proper versioning
3643
3744 - name : Setup Python
38- uses : actions/setup-python@v5
45+ uses : actions/setup-python@v6
3946 with :
4047 python-version : ${{ env.PYTHON_VERSION }}
4148 cache : ' pip'
4249
4350 - name : Setup Poetry
44- uses : abatilo/actions-poetry@v3
51+ uses : abatilo/actions-poetry@v4
4552 with :
4653 poetry-version : ${{ env.POETRY_VERSION }}
4754
5562 path : .venv
5663 key : poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
5764
58- - name : Set up QEMU
59- uses : docker/setup-qemu-action@v3
60-
61- - name : Set up Docker Buildx
62- uses : docker/setup-buildx-action@v3
63-
64- - name : Setup Terraform
65- uses : hashicorp/setup-terraform@v3
66- with :
67- terraform_version : 1.5.3
68-
6965 - name : Version Management
7066 id : versioning
7167 run : |
@@ -204,23 +200,12 @@ jobs:
204200 if : |
205201 github.ref == 'refs/heads/develop' ||
206202 github.ref == 'refs/heads/main' ||
207- startsWith(github.ref, 'refs/heads/release/')
203+ startsWith(github.ref, 'refs/heads/release/') ||
204+ github.event.head_commit.message == '/deploy sit' ||
205+ github.event.head_commit.message == '/deploy uat'
208206 run : |
209207 pip install tenacity logging
210208 python3 ${GITHUB_WORKSPACE}/.github/workflows/wait-for-pypi.py ${{env.pyproject_name}}[harmony]==${{ env.new_version }}
211-
212- - name : Log in to the Container registry
213- if : |
214- github.ref == 'refs/heads/develop' ||
215- github.ref == 'refs/heads/main' ||
216- startsWith(github.ref, 'refs/heads/release') ||
217- github.event.head_commit.message == '/deploy sit' ||
218- github.event.head_commit.message == '/deploy uat'
219- uses : docker/login-action@v3
220- with :
221- registry : ${{ env.REGISTRY }}
222- username : ${{ github.actor }}
223- password : ${{ secrets.GITHUB_TOKEN }}
224209
225210 - name : Deploy Env Override
226211 if : |
@@ -240,43 +225,81 @@ jobs:
240225 lowercase_value=$(echo "${original_env_value}" | tr '[:upper:]' '[:lower:]')
241226 echo "TARGET_ENV_LOWERCASE=${lowercase_value}" >> $GITHUB_ENV
242227
243- - name : Extract metadata (tags, labels) for Docker
228+ - name : Set Build Source
229+ id : set-source
230+ run : |
231+ # Use test PyPI package format (Dockerfile will find it via extra-index-url)
232+ echo "SOURCE=${{ env.pyproject_name }}==${{ env.new_version }}" >> $GITHUB_ENV
233+
234+ - name : Set build outputs
235+ id : build-outputs
236+ run : |
237+ echo "new_version=${{ env.new_version }}" >> $GITHUB_OUTPUT
238+ echo "pyproject_name=${{ env.pyproject_name }}" >> $GITHUB_OUTPUT
239+ echo "target_env_uppercase=${{ env.TARGET_ENV_UPPERCASE }}" >> $GITHUB_OUTPUT
240+ echo "target_env_lowercase=${{ env.TARGET_ENV_LOWERCASE }}" >> $GITHUB_OUTPUT
241+ echo "source=${{ env.SOURCE }}" >> $GITHUB_OUTPUT
242+
243+ - name : Upload terraform zip artifact
244244 if : |
245245 github.ref == 'refs/heads/develop' ||
246246 github.ref == 'refs/heads/main' ||
247247 startsWith(github.ref, 'refs/heads/release') ||
248248 github.event.head_commit.message == '/deploy sit' ||
249- github.event.head_commit.message == '/deploy uat'
249+ github.event.head_commit.message == '/deploy uat'
250+ uses : actions/upload-artifact@v4
251+ with :
252+ name : terraform-zip
253+ path : tig-terraform-${{ env.new_version }}.zip
254+ retention-days : 1
255+
256+ deploy :
257+ name : Deploy Docker and Terraform
258+ runs-on : ubuntu-24.04-arm
259+ needs : build
260+ if : |
261+ github.ref == 'refs/heads/develop' ||
262+ github.ref == 'refs/heads/main' ||
263+ startsWith(github.ref, 'refs/heads/release') ||
264+ github.event.head_commit.message == '/deploy sit' ||
265+ github.event.head_commit.message == '/deploy uat'
266+ permissions :
267+ contents : read
268+ packages : write
269+ id-token : write
270+
271+ steps :
272+ - uses : actions/checkout@v6
273+ with :
274+ fetch-depth : 0
275+
276+ - name : Set deployment variables from build outputs
277+ run : |
278+ echo "NEW_VERSION=${{ needs.build.outputs.new_version }}" >> $GITHUB_ENV
279+ echo "PYPROJECT_NAME=${{ needs.build.outputs.pyproject_name }}" >> $GITHUB_ENV
280+ echo "TARGET_ENV_UPPERCASE=${{ needs.build.outputs.target_env_uppercase }}" >> $GITHUB_ENV
281+ echo "TARGET_ENV_LOWERCASE=${{ needs.build.outputs.target_env_lowercase }}" >> $GITHUB_ENV
282+ echo "SOURCE=${{ needs.build.outputs.source }}" >> $GITHUB_ENV
283+
284+ - name : Log in to the Container registry
285+ uses : docker/login-action@v3
286+ with :
287+ registry : ${{ env.REGISTRY }}
288+ username : ${{ github.actor }}
289+ password : ${{ secrets.GITHUB_TOKEN }}
290+
291+ - name : Extract metadata (tags, labels) for Docker
250292 id : meta
251293 uses : docker/metadata-action@v5
252294 with :
253295 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
254296 flavor : |
255297 latest=${{ github.ref == 'refs/heads/main' }}
256298 tags : |
257- type=pep440,pattern={{version}},value=${{ env.new_version }}
299+ type=pep440,pattern={{version}},value=${{ env.NEW_VERSION }}
258300 type=raw,value=${{ env.TARGET_ENV_LOWERCASE }}
259301
260- - name : Set Build Source
261- id : set-source
262- run : |
263- # Default build source for standard branches
264- echo "SOURCE=${{ env.pyproject_name }}==${{ env.new_version }}" >> $GITHUB_ENV
265-
266- if [[ "${{ contains(github.event.head_commit.message, '/deploy sit') ||
267- contains(github.event.head_commit.message, '/deploy uat') }}" == "true" ]]; then
268- local_tig=$(find dist -type f -name "*.whl")
269- echo "SOURCE=${local_tig}" >> $GITHUB_ENV
270- echo "DIST_PATH=dist/" >> $GITHUB_ENV
271- fi
272-
273302 - name : Build and Push Docker Image
274- if : |
275- github.ref == 'refs/heads/develop' ||
276- github.ref == 'refs/heads/main' ||
277- startsWith(github.ref, 'refs/heads/release') ||
278- github.event.head_commit.message == '/deploy sit' ||
279- github.event.head_commit.message == '/deploy uat'
280303 uses : docker/build-push-action@v6
281304 with :
282305 context : .
@@ -288,38 +311,33 @@ jobs:
288311 platforms : linux/arm64
289312 build-args : |
290313 SOURCE=${{ env.SOURCE }}
291- DIST_PATH=${{ env.DIST_PATH || '' }}
292- cache-from : type=registry,ref=ghcr.io/${{ github.repository }}/cache:tig-cache
293- cache-to : type=registry,ref=ghcr.io/${{ github.repository }}/cache:tig-cache,mode=max
314+
315+ - name : Setup Terraform
316+ uses : hashicorp/setup-terraform@v3
317+ with :
318+ terraform_version : 1.5.3
319+
320+ - name : Get Docker image tag
321+ id : docker-tag
322+ run : |
323+ # Extract the first tag (version tag) from metadata output
324+ DOCKER_IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
325+ echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}" >> $GITHUB_ENV
326+ echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}" >> $GITHUB_OUTPUT
294327
295328 - name : Deploy Terraform
296- if : |
297- github.ref == 'refs/heads/develop' ||
298- github.ref == 'refs/heads/main' ||
299- startsWith(github.ref, 'refs/heads/release') ||
300- github.event.head_commit.message == '/deploy sit' ||
301- github.event.head_commit.message == '/deploy uat'
302329 working-directory : terraform_deploy/
303330 env :
304331 AWS_ACCESS_KEY_ID : ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
305332 AWS_SECRET_ACCESS_KEY : ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
306333 AWS_ACCOUNT_ID : ${{ secrets[format('AWS_ACCOUNT_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}
307334 AWS_DEFAULT_REGION : us-west-2
308335
309- TF_VAR_tig_docker_image : " ghcr.io/podaac/tig: ${{ env.DOCKER_METADATA_OUTPUT_VERSION }}"
336+ TF_VAR_tig_docker_image : ${{ env.DOCKER_IMAGE_TAG }}
310337 TF_VAR_EARTH_DATA_LOGIN_CLIENT_ID : ${{ secrets[format('EARTH_DATA_LOGIN_CLIENT_ID_{0}', env.TARGET_ENV_UPPERCASE)] }}
311338 TF_VAR_EARTH_DATA_LOGIN_PASSWORD : ${{ secrets[format('EARTH_DATA_LOGIN_PASSWORD_{0}', env.TARGET_ENV_UPPERCASE)] }}
312339 run : |
313- ls -al
314- ls -al bin/
315- which python3
316- python3 --version
317- python3 override.py https://github.com/podaac/tig/releases/download/${{ env.new_version }}/tig-terraform-${{ env.new_version }}.zip "ghcr.io/podaac/tig:${{ env.DOCKER_METADATA_OUTPUT_VERSION }}"
318- ls -al
319- echo "Show override contents"
320- cat override.tf.json
321- echo "End show override contents"
322- terraform --version
340+ python3 override.py https://github.com/podaac/tig/releases/download/${{ env.NEW_VERSION }}/tig-terraform-${{ env.NEW_VERSION }}.zip "${{ env.DOCKER_IMAGE_TAG }}"
323341 source bin/config.sh ${{ env.TARGET_ENV_LOWERCASE }}
324- terraform plan -var-file=tfvars/"${{ env.TARGET_ENV_LOWERCASE }}".tfvars -var="app_version=${{ env.new_version }}" -out="tfplan"
325- terraform apply -auto-approve tfplan > /dev/null
342+ terraform plan -var-file=tfvars/"${{ env.TARGET_ENV_LOWERCASE }}".tfvars -var="app_version=${{ env.NEW_VERSION }}" -out="tfplan"
343+ terraform apply -auto-approve tfplan > /dev/null
0 commit comments