mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
47 lines
1.3 KiB
YAML
47 lines
1.3 KiB
YAML
name: Build, Push and Update Image in Manifest
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-update:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USER }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push Docker image
|
|
id: build
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./cd-test
|
|
push: true
|
|
tags: ghcr.io/${{ secrets.DOCKER_USER }}/cd-test:latest
|
|
|
|
- name: Get image digest
|
|
# docker/build-push-action outputs `digest` automatically
|
|
run: echo "IMAGE_DIGEST=${{ steps.build.outputs.digest }}" >> $GITHUB_ENV
|
|
|
|
- name: Update manifest with new image digest
|
|
uses: OpsVerseIO/image-updater-action@0.1.0
|
|
with:
|
|
valueFile: 'cd-test/guestbook-ui-deployment.yaml'
|
|
propertyPath: 'spec.template.spec.containers[0].image'
|
|
# zapíšeme image s digestem
|
|
value: ${{ secrets.DOCKER_USER }}/cd-test@${{ env.IMAGE_DIGEST }}
|
|
commitChange: true
|
|
message: "Update image to digest ${{ env.IMAGE_DIGEST }}"
|
|
|