ci: add cd #2
Workflow file for this run
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
name: Build & Push New Model | |
on: | |
push: | |
branches: | |
- "ci/new-model-deploy" | |
env: | |
PROJECT_ID: boostcamp-ai-tech-serving # TODO: replace this with your project | |
REGION: ap-norhteast3 | |
ZONE: ap-norhteast3-a | |
REPOSITORY: model_deploy | |
IMAGE: main | |
GCE_INSTANCE: boostcamp | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Docker build' | |
run: |- | |
docker build \ | |
--tag "$REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" \ | |
new/model_deploy | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v0.6.0' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
token_format: 'access_token' | |
- uses: 'docker/login-action@v1' | |
name: 'Docker login' | |
with: | |
registry: '${{ env.REGION }}-docker.pkg.dev' | |
username: 'oauth2accesstoken' | |
password: '${{ steps.auth.outputs.access_token }}' | |
- name: 'Docker push' | |
run: |- | |
docker push "$REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" | |
cd: | |
runs-on: ubuntu-latest | |
needs: [ci] | |
steps: | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v0.6.0' | |
with: | |
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | |
token_format: 'access_token' | |
- name: Deploy | |
run: |- | |
gcloud compute instances update-container "$GCE_INSTANCE" \ | |
--zone "$GCE_INSTANCE_ZONE" \ | |
--container-image "$REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$IMAGE:$GITHUB_SHA" |