Merge pull request #5 from Hazunanafaru/ILT-6-initial-setup #12
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 Google Container Registry | |
# create simple trigger based on everytime we create new tag in this repository | |
on: | |
push: | |
tags: | |
# Push events to every tag including hierarchical tags like v1.0/beta | |
- "**" | |
jobs: | |
BuildPush: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Setup Environment Variables | |
run: |- | |
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV" | |
echo "ILT_NAME=$(echo ${{ github.ref_name }} | cut -d "/" -f1)" >> "$GITHUB_ENV" | |
echo "ILT_VERSION=$(echo ${{ github.ref_name}} | cut -d "/" -f2)" >> "$GITHUB_ENV" | |
- name: Checkout Code | |
uses: actions/checkout@v1 | |
- name: Login to GCR | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }} | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
export_default_credentials: true | |
- name: Build Docker Image | |
run: |- | |
cd ${{ github.workspace }}/$ILT_NAME | |
docker build -t $ILT_NAME:$ILT_VERSION -f ./Dockerfile.prod . | |
- name: Configure Docker Client | |
run: gcloud auth configure-docker --quiet | |
- name: Push Docker Image to Google Container Registry | |
run: |- | |
docker tag $ILT_NAME:$ILT_VERSION gcr.io/$GCP_PROJECT/$ILT_NAME:$ILT_VERSION | |
docker push gcr.io/$GCP_PROJECT/$ILT_NAME:$ILT_VERSION |