Skip to content

Merge pull request #369 from ASFHyP3/dependabot/pip/pip-deps-2522c05591 #183

Merge pull request #369 from ASFHyP3/dependabot/pip/pip-deps-2522c05591

Merge pull request #369 from ASFHyP3/dependabot/pip/pip-deps-2522c05591 #183

name: Build image and deploy
on:
pull_request:
branches:
- main
- develop
push:
branches:
- develop
tags:
- 'v*'
jobs:
call-version-info-workflow:
uses: ASFHyP3/actions/.github/workflows/reusable-version-info.yml@v0.21.1
permissions:
contents: read
with:
python_version: '3.12'
dockerize:
needs: call-version-info-workflow
runs-on: ubuntu-latest
concurrency:
group: ${{ needs.call-version-info-workflow.outputs.version_tag }}
cancel-in-progress: true
permissions:
contents: read
env:
ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
VERSION_TAG: ${{ needs.call-version-info-workflow.outputs.version_tag }}
PLATFORMS: 'linux/amd64'
outputs:
image_uri: ${{ steps.set_outputs.outputs.IMAGE_URI }}
steps:
- uses: actions/checkout@v7
- name: set env and outputs
id: set_outputs
run: |
export ECR_REPOSITORY=${GITHUB_REPOSITORY,,}
echo "ECR_REPOSITORY=${ECR_REPOSITORY}" >> ${GITHUB_ENV}
export IMAGE_URI=${ECR_REGISTRY}/${ECR_REPOSITORY}:${VERSION_TAG}
echo "IMAGE_URI=${IMAGE_URI}" >> ${GITHUB_ENV}
echo "IMAGE_URI=${IMAGE_URI}" >> ${GITHUB_OUTPUT}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
platforms: ${{ env.PLATFORMS }}
- uses: aws-actions/configure-aws-credentials@v6
if: ${{ github.actor != 'dependabot[bot]' }}
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
if: ${{ github.actor != 'dependabot[bot]' }}
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build
uses: docker/build-push-action@v7
with:
build-args: "SETUPTOOLS_SCM_PRETEND_VERSION=${{ needs.call-version-info-workflow.outputs.version }}"
push: ${{ ! github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
platforms: ${{ env.PLATFORMS }}
provenance: false
tags: |
${{ env.IMAGE_URI }}
- name: Add test tag
if: ${{ github.event_name != 'pull_request' && contains(env.VERSION_TAG, '.dev') }}
uses: akhilerm/tag-push-action@v2.3.0
with:
src: ${{ env.IMAGE_URI }}
dst: ${{ vars.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:test
- name: Add latest tag
if: ${{ github.event_name != 'pull_request' && ! contains(env.VERSION_TAG, '.dev') }}
uses: akhilerm/tag-push-action@v2.3.0
with:
src: ${{ env.IMAGE_URI }}
dst: ${{ vars.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ vars.ECR_REGISTRY }}
deploy:
if: ${{ github.event_name != 'pull_request' }}
concurrency:
group: deploy-${{ contains(needs.call-version-info-workflow.outputs.version_tag, '.dev') && 'test' || 'prod' }}
environment: ${{ contains(needs.call-version-info-workflow.outputs.version_tag, '.dev') && 'test' || 'prod' }}
runs-on: ubuntu-latest
needs:
- call-version-info-workflow
- dockerize
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: aws-actions/configure-aws-credentials@v6
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- uses: ./.github/actions/deploy
with:
STACK_NAME: ${{ vars.STACK_NAME }}
EARTHDATA_USERNAME: ${{ secrets.EARTHDATA_USERNAME }}
EARTHDATA_PASSWORD: ${{ secrets.EARTHDATA_PASSWORD }}
CF_TEMPLATE_BUCKET: cf-templates-3o5lnspmwmzg-us-west-2
LANDSAT_TOPIC_ARN: ${{ vars.LANDSAT_TOPIC_ARN }}
NISAR_TOPIC_ARN: ${{ vars.NISAR_TOPIC_ARN }}
SENTINEL1_TOPIC_ARN: ${{ vars.SENTINEL1_TOPIC_ARN }}
SENTINEL2_TOPIC_ARN: ${{ vars.SENTINEL2_TOPIC_ARN }}
HYP3_API: ${{ vars.HYP3_API }}
HYP3_JOBS_TABLE: ${{ vars.HYP3_JOBS_TABLE }}
LAMBDA_LOGGING_LEVEL: INFO
PUBLISH_BUCKET: ${{ vars.PUBLISH_BUCKET }}
STAC_ITEMS_ENDPOINT: ${{ vars.STAC_ITEMS_ENDPOINT }}
STAC_EXISTS_OK: ${{ vars.STAC_EXISTS_OK }}
ECR_IMAGE_URI: ${{ needs.dockerize.outputs.image_uri }}