Last active
October 3, 2020 02:07
-
-
Save leozz37/dd68cc1023238504cda7c011322d7c3f to your computer and use it in GitHub Desktop.
GitHub Actions Workflow Cloud Run deploy script
This file contains hidden or 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: Docker | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
deploy: | |
name: Setup Gcloud Account | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }} | |
steps: | |
- name: Login | |
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master | |
with: | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_email: ${{ secrets.GCP_EMAIL }} | |
service_account_key: ${{ secrets.GCP_CREDENTIALS }} | |
- name: Configure Docker | |
run: gcloud auth configure-docker --quiet | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: docker build . -t $IMAGE_NAME | |
- name: Test Docker image | |
run: docker run $IMAGE_NAME sh -c "go test -v" | |
- name: Push Docker image | |
run: docker push $IMAGE_NAME | |
- name: Deploy Docker image | |
run: gcloud run deploy ${{ secrets.GCP_PROJECT_ID }} --image $IMAGE_NAME --region us-central1 --platform managed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment