-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vggonzal
authored and
vggonzal
committed
Oct 18, 2023
1 parent
8b54bd2
commit 3b49874
Showing
1 changed file
with
57 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,11 +162,61 @@ jobs: | |
poetry run pytest tests/test_hydrocron_database.py | ||
poetry run pytest tests/test_io_swot_reach_node_shp.py | ||
## Set environment variables | ||
- name: Configure Initial YAML file and environment variables | ||
run: | | ||
echo "THE_VERSION=${{ env.software_version }}" >> $GITHUB_ENV; | ||
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV; | ||
GITHUB_REF_READABLE="${GITHUB_REF//\//-}" | ||
echo "GITHUB_REF_READABLE=${GITHUB_REF_READABLE}" >> $GITHUB_ENV | ||
echo "THE_ENV=sit" >> $GITHUB_ENV | ||
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV | ||
# Setup docker to build and push images | ||
- name: Log in to the Container registry | ||
if: ${{ startsWith(github.ref, 'test') }} | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
if: ${{ startsWith(github.ref, 'test') }} | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=semver,pattern={{version}},value=${{ env.THE_VERSION }} | ||
type=raw,value=${{ env.THE_ENV }} | ||
- name: Build and push Docker image | ||
if: ${{ startsWith(github.ref, 'test') }} | ||
#if: | | ||
# github.ref == 'refs/heads/develop' || | ||
# github.ref == 'refs/heads/main' || | ||
# startsWith(github.ref, 'refs/heads/release') || | ||
# github.event.head_commit.message == '/deploy sit' || | ||
# github.event.head_commit.message == '/deploy uat' | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: docker/Dockerfile | ||
push: true | ||
pull: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
|
||
# Setup Terraform to Deploy | ||
|
||
- name: Configure AWS Credentials as Environment Variables | ||
run: echo "AWS_ACCESS_KEY_ID=${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV | | ||
echo "AWS_SECRET_ACCESS_KEY=${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV | ||
echo "AWS_SECRET_ACCESS_KEY=${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }}" >> $GITHUB_ENV | ||
|
||
- name: Validate AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
|
@@ -182,16 +232,6 @@ jobs: | |
with: | ||
terraform_version: 1.0.3 | ||
|
||
|
||
# -- Build -- | ||
- name: Build lambda package | ||
run: ./build.sh | ||
- name: Upload packaged zip | ||
uses: actions/[email protected] | ||
with: | ||
name: dist | ||
path: dist/*.zip | ||
|
||
- name: Deploy Terraform | ||
#if: | | ||
# github.ref == 'refs/heads/develop' || | ||
|
@@ -201,12 +241,14 @@ jobs: | |
# github.event.head_commit.message == '/deploy uat' | ||
working-directory: terraform/ | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | ||
AWS_DEFAULT_REGION: us-west-2 | ||
AWS_ACCESS_KEY_ID: ${{ secrets[format('AWS_ACCESS_KEY_ID_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_SERVICES_{0}', env.TARGET_ENV_UPPERCASE)] }} | ||
AWS_DEFAULT_REGION: us-west-2 | ||
|
||
TF_VAR_hydrocronapi_api_docker_image: "ghcr.io/podaac/hydrocron:${{ env.THE_VERSION }}" | ||
|
||
run: | | ||
source bin/config.sh ${{ env.THE_ENV }} | ||
#source bin/config.sh ${{ env.THE_ENV }} | ||
terraform init -reconfigure -backend-config="bucket=podaac-services-${{ env.THE_ENV }}-terraform" -backend-config="region=us-west-2" | ||
terraform plan -var-file=tfvars/"${{ env.THE_ENV }}".tfvars -var="app_version=${{ env.THE_VERSION }}" -out="tfplan" | ||
terraform apply -auto-approve tfplan |