-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (115 loc) · 4.51 KB
/
Copy pathbuild-and-deploy.yml
File metadata and controls
130 lines (115 loc) · 4.51 KB
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
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.0
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@v6
- 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.2.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.2.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@v6
- 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 }}