Merge pull request #49 from kartverket/catalog-update #32
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 Image to Registry | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
packages: write | |
env: | |
registry: ghcr.io | |
image_name: ${{ github.repository }} | |
jobs: | |
build: | |
name: Docker build and push | |
runs-on: ubuntu-latest | |
outputs: | |
image_name: ${{ steps.set_outputs.outputs.image_name }} | |
new_tag: ${{ steps.set_outputs.outputs.new_tag }} | |
new_digest: ${{ steps.set_outputs.outputs.new_digest }} | |
steps: | |
- name: Checkout project sources | |
uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.registry }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Bump version and push tag | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.2 | |
with: | |
github_token: ${{ github.token }} | |
- name: Build docker and push | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.registry }}/${{ github.repository }}:${{ steps.tag_version.outputs.new_tag }} , ${{ env.registry }}/${{ github.repository }}:latest | |
- name: Set outputs | |
id: set_outputs | |
run: | | |
echo 'image_name=${{ env.registry }}/${{ github.repository }}' >> $GITHUB_OUTPUT | |
echo 'new_digest=${{ steps.build.outputs.digest }}' >> $GITHUB_OUTPUT | |
echo 'new_tag=${{ steps.tag_version.outputs.new_tag }}' >> $GITHUB_OUTPUT | |
- name: Add summary of build | |
id: summary | |
run: | | |
echo '### Image release info' >> $GITHUB_STEP_SUMMARY | |
echo '- Image name: ${{ env.registry }}/${{ github.repository }}' >> $GITHUB_STEP_SUMMARY | |
echo '- Digest: ${{ steps.build.outputs.digest }}' >> $GITHUB_STEP_SUMMARY | |
echo '- Tag: ${{ steps.tag_version.outputs.new_tag }}' >> $GITHUB_STEP_SUMMARY | |
deploy: | |
needs: [ build ] | |
name: Deploy to dev | |
uses: kartverket/bygning-github-workflows/.github/workflows/update-app-version.yaml@main | |
permissions: | |
id-token: write | |
with: | |
application_name: bygning-backend | |
image_name: ${{ needs.build.outputs.image_name }} | |
image_tag: ${{ needs.build.outputs.new_tag }} | |
image_digest: ${{ needs.build.outputs.new_digest }} | |
env: dev | |
namespace: matrikkelbygning-main | |
cluster: atgcp1 | |
run-pharos: | |
needs: [ build ] | |
name: Run Pharos | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
packages: read | |
contents: read | |
security-events: write | |
steps: | |
- name: "Run Pharos" | |
uses: kartverket/pharos@v0.2.1 | |
with: | |
image_url: ${{ needs.build.outputs.image_name }}@${{ needs.build.outputs.new_digest }} |