mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 06:57:47 +01:00
feat(infrastructure): test basic workflow
This commit is contained in:
46
.github/workflows/workflow.yml
vendored
Normal file
46
.github/workflows/workflow.yml
vendored
Normal file
@@ -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 }}"
|
||||||
|
|
||||||
2
cd-test/Dockerfile
Normal file
2
cd-test/Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FROM httpd
|
||||||
|
RUN echo "<html><body><h1>Current Date and Time</h1><p>$(date)</p></body></html>" > /usr/local/apache2/htdocs/index.html
|
||||||
Reference in New Issue
Block a user