Build and Push UI #94
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 UI | |
on: | |
create: | |
# Environment variables available to all jobs and steps in this workflow | |
env: | |
GKE_PROJECT: ${{ secrets.GCP_PROJECT }} | |
GKE_EMAIL: ${{ secrets.GCP_EMAIL }} | |
GITHUB_SHA: ${{ github.sha }} | |
IMAGE: screen-ui | |
REGISTRY_HOSTNAME: gcr.io | |
jobs: | |
setup-build-publish-ui: | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
name: Setup, Build, Publish UI | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ secrets.GCP_WORKLOAD }} | |
service_account: ${{ secrets.GCP_EMAIL }} | |
# Setup gcloud CLI | |
- uses: google-github-actions/setup-gcloud@v1 | |
with: | |
version: '270.0.0' | |
service_account_email: ${{ secrets.GCP_EMAIL }} | |
service_account_key: ${{ secrets.GCP_KEY }} | |
- name: Setup Python 3.8 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Login to GCR | |
uses: docker/login-action@v2 | |
with: | |
registry: $REGISTRY_HOSTNAME | |
username: _json_key | |
password: ${{ secrets.GCR_SERVICE_KEY }} | |
# Configure docker to use the gcloud command-line tool as a credential helper | |
- run: | | |
# Set up docker to authenticate | |
# via gcloud command-line tool. | |
gcloud auth configure-docker | |
# Build the Docker image | |
- name: Build | |
run: | | |
docker build -t image \ | |
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | |
--build-arg GITHUB_REF="$GITHUB_REF" website | |
# Push the Docker image to Google Container Registry | |
- name: Publish | |
run: | | |
docker tag image "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$GITHUB_SHA" && \ | |
docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:$GITHUB_SHA |