Build and Push to GCR #44
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 and Push to GCR | |
on: | |
push: | |
tags: ['**'] | |
branches-ignore: ['**'] | |
env: | |
PROJECT_ID: ${{ vars.GCR_PROJECT }} | |
REGISTRY: ${{ vars.GCR_HOSTNAME }} | |
IMAGE: officectl | |
jobs: | |
setup-build-push: | |
name: Setup, Build and Push | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Setup gcloud CLI | |
- uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_GITHUB_SA_CREDENTIALS_FOR_PUBLIC_REPOS }} | |
- uses: google-github-actions/[email protected] | |
with: | |
version: '415.0.0' | |
project_id: ${{ vars.GCP_PROJECT }} | |
# Configure Docker to use the gcloud command-line tool as a credential | |
# helper for authentication | |
- run: gcloud --quiet auth configure-docker | |
- name: Get tag name | |
id: get_tag | |
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} | |
# Build the Docker image | |
- name: Build | |
run: |- | |
docker build \ | |
--tag "$REGISTRY/$PROJECT_ID/$IMAGE:${{ steps.get_tag.outputs.TAG }}" \ | |
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | |
--build-arg GITHUB_REF="$GITHUB_REF" \ | |
. | |
# Push the Docker image to Google Container Registry | |
- name: Push | |
run: docker push "$REGISTRY/$PROJECT_ID/$IMAGE:${{ steps.get_tag.outputs.TAG }}" |