Skip to content

Merge pull request #74 from Bot-detector/develop #8

Merge pull request #74 from Bot-detector/develop

Merge pull request #74 from Bot-detector/develop #8

name: hetzner production workflow
# Controls when the workflow will run
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions: write-all
env:
VALUE_FILE: bd-web-prd/deployment.yaml
REGISTRY: quay.io/bot_detector/bd-web
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build_image:
# The type of runner that the job will run on
runs-on: [self-hosted,hetzner]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: git checkout
uses: actions/checkout@v3
- name: Set vars
id: vars
run: |
echo "GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
echo "REGISTRY=$REGISTRY" >> $GITHUB_OUTPUT
echo "VALUE_FILE=$VALUE_FILE" >> $GITHUB_OUTPUT
# Runs a command using the runners shell
- name: docker build
run: docker build . --file Dockerfile --network=host --target production -t "$REGISTRY:${{ steps.vars.outputs.GIT_HASH }}"
- name: login to registry
run: echo "${{ secrets.QUAY_REGISTERY_PASSWORD }}" | docker login -u="bot_detector+quay_robot" quay.io --password-stdin
- name: docker push image to registry
run: docker push "$REGISTRY:${{ steps.vars.outputs.GIT_HASH }}"
- name: Checkout Target Repository
uses: actions/checkout@v3
with:
repository: Bot-detector/bot-detector-k8s
- name: Update Image Version
uses: fjogeleit/yaml-update-action@main
with:
repository: Bot-detector/bot-detector-k8s
valueFile: "${{ steps.vars.outputs.VALUE_FILE }}"
token: ${{ secrets.HETZNER_ACTIONS_RUNNER_TOKEN }}
commitChange: true
branch: "${{ steps.vars.outputs.GIT_HASH }}"
targetBranch: develop
masterBranchName: develop
createPR: true
changes: |
{
"spec.template.spec.containers[0].image":"${{ steps.vars.outputs.REGISTRY }}:${{ steps.vars.outputs.GIT_HASH }}"
}