Staging Release #242
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 docker | |
on: | |
push: | |
branches: | |
- develop | |
- staging | |
- main | |
env: | |
IMAGE_NAME: europe-docker.pkg.dev/jumper-g-artifacts/docker-jumper-exchange/jumpex | |
jobs: | |
build-docker: | |
runs-on: ubuntu-latest | |
# id token | |
permissions: | |
contents: "read" | |
id-token: "write" | |
steps: | |
- # check out the repository | |
name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set current date as env variable | |
run: echo "UNIQ_ID=$(date +'%y%m%d')-${GITHUB_SHA:0:7}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Authenticate to Google Cloud | |
id: gcpauth | |
uses: google-github-actions/auth@v2 | |
with: | |
create_credentials_file: 'true' | |
workload_identity_provider: 'projects/800848389157/locations/global/workloadIdentityPools/github/providers/github' | |
service_account: '[email protected]' | |
- # login to gcp | |
name: login | |
run: |- | |
gcloud auth login --brief --cred-file="${{ steps.gcpauth.outputs.credentials_file_path }}" | |
gcloud auth configure-docker europe-docker.pkg.dev | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=branch,prefix=${{ env.UNIQ_ID }}- | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
ENV_FILE=${{ github.ref_name == 'main' && '.env.production' || github.ref_name == 'develop' && '.env.development' || format('.env.{0}', github.ref_name) }} | |
ENV_NAME=${{ github.ref_name == 'main' && 'prod' || github.ref_name }} |