This repository has been archived by the owner on Oct 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sep 29, 2023
1 parent
cd05fdb
commit 263d970
Showing
1 changed file
with
0 additions
and
93 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 |
---|---|---|
|
@@ -160,96 +160,3 @@ jobs: | |
run: | | ||
poetry run pytest tests/test_api.py -k 'test_gettimeseries_get' | ||
poetry run pytest tests/test_api.py -k 'test_getsubset_get' | ||
## 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 | ||
|
||
- name: Validate AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-region: us-west-2 | ||
role-session-name: GitHubActions | ||
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)] }} | ||
- run: aws sts get-caller-identity | ||
|
||
- uses: hashicorp/[email protected] | ||
with: | ||
terraform_version: 1.0.3 | ||
|
||
- name: Deploy Terraform | ||
#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' | ||
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 | ||
|
||
TF_VAR_hydrocronapi_api_docker_image: "ghcr.io/podaac/hydrocron:${{ env.THE_VERSION }}" | ||
|
||
run: | | ||
echo "-------" | ||
echo ${{ env.THE_ENV }} | ||
echo ${{ env.THE_VERSION }} | ||
terraform init -reconfigure -backend-config="bucket=podaac-services-sit-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 |