diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..7d3ddc9 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,46 @@ +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 }}" + diff --git a/cd-test/Dockerfile b/cd-test/Dockerfile new file mode 100644 index 0000000..8b7919a --- /dev/null +++ b/cd-test/Dockerfile @@ -0,0 +1,2 @@ +FROM httpd +RUN echo "

Current Date and Time

$(date)

" > /usr/local/apache2/htdocs/index.html