Skip to content

Commit

Permalink
Use GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjtaylor committed Jun 5, 2024
1 parent 4ab1ab7 commit 8bbc7b1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
57 changes: 45 additions & 12 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,50 @@ on:
- redeploy-action
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
deploy:
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout GitHub Action
uses: actions/checkout@v3

- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=sha
latest
- name: Build and push to GHCR
uses: docker/build-push-action@v4
with:
context: ./docker
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

deploy-cloud-run:
runs-on: ubuntu-latest

steps:
Expand All @@ -25,15 +67,6 @@ jobs:
with:
project_id: htan-dcc

- name: Log in to Google Artifact Registry
run: gcloud auth configure-docker us-docker.pkg.dev

- name: Build and push Docker image
run: |
cd src
docker build . -t us-docker.pkg.dev/htan-dcc/gcr.io/data-release-validation:${{ github.sha }}
docker push us-docker.pkg.dev/htan-dcc/gcr.io/data-release-validation:${{ github.sha }}
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
Expand All @@ -43,7 +76,7 @@ jobs:
run: terraform init

- name: Terraform Plan
run: terraform plan -var="image_tag=${{ github.sha }}"
run: terraform plan

- name: Terraform Apply
run: terraform apply -var="image_tag=${{ github.sha }}" -auto-approve
run: terraform apply -auto-approve
2 changes: 1 addition & 1 deletion terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project_id = "htan-dcc"
region = "us-east1"
image_url = "us-docker.pkg.dev/htan-dcc/gcr.io/data-release-validation:latest"
image_url = "ghcr.io/ncihtan/data-release-cloud-run:latest"
secret_id = "synapse_service_pat"

# service account variables
Expand Down

0 comments on commit 8bbc7b1

Please sign in to comment.