Merge pull request #78 from mitsuki-jpg/develop #33
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: hetzner development 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: [ develop ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: write-all | |
env: | |
VALUE_FILE: bd-web-dvp/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 -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 }}" | |
} |