-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made changes for deployment to bip (#95)
* added workflow for build and push
- Loading branch information
Showing
2 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build and Deploy Docker Image | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
paths: | ||
- 'src/**' | ||
- 'server.js' | ||
- 'index.html' | ||
- 'tsconfig.json' | ||
- 'tsconfig.node.json' | ||
- 'vite.config.ts' | ||
- 'package.json' | ||
- 'package-lock.json' | ||
- 'Dockerfile' | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REGISTRY: europe-north1-docker.pkg.dev/artifact-registry-5n/dapla-stat-docker/dapla-ctrl | ||
IMAGE: dapla-ctrl | ||
TAG: ${{ github.ref_name }}-${{ github.sha }} | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- id: "auth" | ||
name: "Authenticate to Google Cloud" | ||
uses: "google-github-actions/[email protected]" | ||
with: | ||
workload_identity_provider: "projects/848539402404/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" | ||
service_account: "gh-actions-dapla-stat@artifact-registry-5n.iam.gserviceaccount.com" | ||
token_format: "access_token" | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: "oauth2accesstoken" | ||
password: "${{ steps.auth.outputs.access_token }}" | ||
|
||
- name: Determine Tag | ||
id: tag | ||
run: | | ||
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then | ||
echo "::set-output name=version::latest" | ||
elif [[ "${{ github.event_name }}" == "release" ]]; then | ||
echo "::set-output name=version::${{ github.event.release.tag_name }}" | ||
else | ||
echo "::set-output name=version::$(date +'%Y%m%d%H%M%S')" | ||
fi | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ steps.tag.outputs.version }} | ||
build-args: | | ||
BASE_IMAGE=${{ env.REGISTRY }}/base-image:latest |
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