Skip to content

Merge pull request #20 from Fedodo/dev #19

Merge pull request #20 from Fedodo/dev

Merge pull request #20 from Fedodo/dev #19

name: HugoBuildAndDeploy
on:
workflow_dispatch:
push:
branches: [main]
env:
NAME: ./
CONTAINER-NAME: fedodo-home
jobs:
ReleaseVersion:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v3
# Install Hugo
- name: Hugo setup
uses: peaceiris/actions-hugo@v2.5.0
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: fedodo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
run: docker build . --file ./${{ env.NAME }}/Dockerfile --tag fedodo/${{ env.CONTAINER-NAME }}:${{ github.run_number }}
- name: Push the image to dockerhub
run: docker push fedodo/${{ 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/actions-hugo@v2.5.0
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: fedodo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
run: docker build . --file ./${{ env.NAME }}/Dockerfile --tag fedodo/${{ env.CONTAINER-NAME }}:latest
- name: Push the image to dockerhub
run: docker push fedodo/${{ env.CONTAINER-NAME }}:latest
DeployContainer:
needs: ReleaseVersion
runs-on: ubuntu-latest
steps:
# Download Secure-File
- name: base64-to-file
id: write_file
uses: timheuer/base64-to-file@v1.1
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/Kubernetes.yaml --kubeconfig ${{ steps.write_file.outputs.filePath }}