Skip to content

Commit

Permalink
update deploy package
Browse files Browse the repository at this point in the history
  • Loading branch information
wilberh committed Aug 30, 2023
1 parent 9713e52 commit c43c548
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ jobs:
runs-on: ubuntu-latest
needs: [health-check-job] # will be fired if and only if health-check-job is passed.
if: ${{ github.event_name == 'push' }} # will be fired if the trigger event is a push event.
env:
ARTIFACT_LOC1: us-central1
steps:
- name: Checkout Code # checking out code.
uses: actions/checkout@v3
Expand All @@ -69,24 +71,27 @@ jobs:
with:
token_format: access_token
credentials_json: ${{ secrets.GH_GCR_SERVICE_ACCT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
- name: Use gcloud CLI
run: gcloud info
- name: Install gke-gcloud-auth-plugin
run: |
gcloud components install gke-gcloud-auth-plugin
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |
gcloud --quiet auth configure-docker
# - name: Set up Cloud SDK
# uses: google-github-actions/setup-gcloud@v1
# - name: Use gcloud CLI
# run: gcloud info
# - name: Install gke-gcloud-auth-plugin
# run: |
# gcloud components install gke-gcloud-auth-plugin
# # Configure Docker to use the gcloud command-line tool as a credential
# # helper for authentication
# - run: |
# gcloud --quiet auth configure-docker
- name: Set Image Name
id: image
run: echo "image_name=app:sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set Repo Location # steps required to find the image id of our image from GCP Artifactory container registry
id: repo
run: echo "repo_name=gcr.io/${{secrets.GKE_PROJECT}}/github-action-aifinance/app:sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Login to Google Artifact Registry - using docker login action
uses: docker/login-action@v2
with:
registry: us-central1-docker.pkg.dev # /${{secrets.GKE_PROJECT}}/github-action-aifinance # gcr.io # or REGION-docker.pkg.dev
registry: $ARTIFACT_LOC1.pkg.dev # /${{secrets.GKE_PROJECT}}/github-action-aifinance # gcr.io # or REGION-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
# This example runs "docker login" directly to Artifact Registry.
Expand All @@ -100,15 +105,16 @@ jobs:
# file: ./Dockerfile
# push: true
# tags: user/app:latest
- name: Build Docker Image
- name: Build Docker Image
run: |
docker build -t app:latest .
- name: Tag Image to Artifact Registry
docker build -t ${{ steps.image.outputs.image_name }} .
- name: Tag Image to Artifact Registry
run: |
docker tag app:latest us-central1-docker.pkg.dev/atlantean-site-393904/github-action-aifinance/app:latest
docker tag ${{ steps.image.outputs.image_name }} ${{ steps.repo.outputs.repo_name }}
- name: Publish Image
run: |
docker image push us-central1-docker.pkg.dev/atlantean-site-393904/github-action-aifinance/app:latest
docker image push ${{ steps.repo.outputs.repo_name }}
# docker image push $ARTIFACT_LOC1-docker.pkg.dev/atlantean-site-393904/github-action-aifinance/$IMAGE_NAME

deploy-job: # deploy job is for deploying our code to google cloud cluster.
runs-on: ubuntu-latest
Expand Down

0 comments on commit c43c548

Please sign in to comment.