Merge pull request #205 from Fachinformatiker-Prufungsvorbereitung/dev #109
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: HugoBuildAndDeploy | |
on: | |
workflow_dispatch: # To have the ability to run the workflow manually | |
push: | |
branches: [main] | |
env: | |
NAME: ./ | |
CONTAINER-NAME: fi-pv | |
jobs: | |
ReleaseVersion: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- uses: actions/checkout@v3 | |
# Install Hugo | |
- name: Hugo setup | |
uses: peaceiris/[email protected] | |
with: | |
extended: true | |
# Build the hugo repository | |
- run: hugo | |
working-directory: ./${{ env.NAME }}/ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build the Docker image | |
run: docker build . --file ./${{ env.NAME }}/deployment/Dockerfile --tag lnadev/${{ env.CONTAINER-NAME }}:${{ github.run_number }} | |
- name: Push the image to dockerhub | |
run: docker push lnadev/${{ env.CONTAINER-NAME }}:${{ github.run_number }} | |
ReleaseLatest: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- uses: actions/checkout@v3 | |
# Install Hugo | |
- name: Hugo setup | |
uses: peaceiris/[email protected] | |
with: | |
extended: true | |
# Build the hugo repository | |
- run: hugo | |
working-directory: ./${{ env.NAME }}/ | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build the Docker image | |
run: docker build . --file ./${{ env.NAME }}/deployment/Dockerfile --tag lnadev/${{ env.CONTAINER-NAME }}:latest | |
- name: Push the image to dockerhub | |
run: docker push lnadev/${{ env.CONTAINER-NAME }}:latest | |
DeployContainer: | |
needs: ReleaseVersion | |
runs-on: ubuntu-latest | |
steps: | |
# Download Secure-File | |
- name: base64-to-file | |
id: write_file | |
uses: timheuer/[email protected] | |
with: | |
fileName: "custom-config" | |
encodedString: ${{ secrets.KUBECTL_CONFIG }} | |
# Checkout the repository | |
- uses: actions/checkout@v3 | |
- name: Find and Replace | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "{{RUN_NUMBER}}" | |
replace: ${{ github.run_number }} | |
regex: false | |
# Deploy Kubernetes YAML | |
- run: kubectl apply -f ./deployment/Fachinformatiker-Prüfungsvorbereitung.yaml --kubeconfig ${{ steps.write_file.outputs.filePath }} |