Skip to content

add k8s deployment

add k8s deployment #3

Workflow file for this run

# yamllint disable rule:comments
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Release Hermes
'on':
push:
branches:
- master
- feat/k8s
env:
SERVICE_NAME: hermes
jobs:
build:
runs-on: arc-runner-set-prod
steps:
- name: Install prerequisites
run: >-
sudo apt-get update &&
sudo apt-get install --yes --no-install-recommends curl git &&
sudo apt-get clean &&
sudo rm -rf /var/lib/apt/lists/*
- name: Generate Token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
id: generate-token
with:
app_id: "${{ secrets.RENOVATEBOT_APP_ID }}"
private_key: "${{ secrets.RENOVATEBOT_APP_PRIVATE_KEY }}"
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: "${{ steps.generate-token.outputs.token }}"
- name: Get build tag
id: vars
run: |-
echo "${{ secrets.IFAD_BOT_SSH_KEY }}" > /tmp/ssh_key
chmod 600 /tmp/ssh_key
echo "docker_image_tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "service_name=${SERVICE_NAME}" >> $GITHUB_OUTPUT
- name: Login to IFAD Registry
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ secrets.HARBOR_URL }}
username: ${{ secrets.HARBOR_USER }}
password: ${{ secrets.HARBOR_PASS }}
- name: Build and push image
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: .
push: true
tags: ${{ secrets.HARBOR_URL }}/services/${{ steps.vars.outputs.service_name }}:${{ steps.vars.outputs.docker_image_tag }}
secret-files: "ssh_private_key=/tmp/ssh_key"
- name: Install ArgoCD
run: |
curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd
export USER=argocd
# The master branch is linked to ArgoCD production, all other branches are linked to ArgoCD staging
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
./argocd login ${{ secrets.PROD_ARGOCD_URL }} --username ${{ secrets.PROD_ARGOCD_USER }} --password ${{ secrets.PROD_ARGOCD_PASS }} --insecure --skip-test-tls --grpc-web
else
./argocd login ${{ secrets.ARGOCD_URL }} --username ${{ secrets.ARGOCD_USER }} --password ${{ secrets.ARGOCD_PASS }} --insecure --skip-test-tls --grpc-web
fi
- name: Configure and Update ArgoCD
run: |
./argocd app set $SERVICE_NAME --plugin-env DEPLOY_TAG="${{ steps.vars.outputs.docker_image_tag }}"
./argocd app get $SERVICE_NAME --hard-refresh
sleep 10
./argocd app sync $SERVICE_NAME
# yamllint enable rule:comments