Skip to content

Merge pull request #49 from openinfradev/harbor #60

Merge pull request #49 from openinfradev/harbor

Merge pull request #49 from openinfradev/harbor #60

Workflow file for this run

name: Build And Deploy
on:
push:
branches:
- main
- develop
- release
workflow_dispatch:
env:
SERVICE: tks-batch
TAG: ${{github.sha}}
REGISTRY: harbor.taco-cat.xyz
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.HARBOR_USERNAME}}
password: ${{secrets.HARBOR_SECRET}}
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: |
${{env.REGISTRY}}/tks/${{env.SERVICE}}:${{env.TAG}}
- name: Setup Kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: "3.6.1"
- run: |
git config --global user.email "[email protected]"
git config --global user.name "tks"
git clone "https://${{secrets.BOT_GITHUB_TOKEN}}@github.com/openinfradev/cicd-manifests.git"
if [[ ${{github.ref}} == *"develop"* ]]; then
( cd cicd-manifests/${SERVICE}/overlay/development && kustomize edit set image ${REGISTRY}/tks/${SERVICE}:${TAG} && git add kustomization.yaml )
elif [[ ${{github.ref}} == *"release"* ]]; then
( cd cicd-manifests/${SERVICE}/overlay/ft && kustomize edit set image ${REGISTRY}/tks/${SERVICE}:${TAG} && git add kustomization.yaml )
elif [[ ${{github.ref}} == *"main"* ]]; then
( cd cicd-manifests/${SERVICE}/overlay/cicd && kustomize edit set image ${REGISTRY}/tks/${SERVICE}:${TAG} && git add kustomization.yaml )
( cd cicd-manifests/${SERVICE}/overlay/prd && kustomize edit set image ${REGISTRY}/tks/${SERVICE}:${TAG} && git add kustomization.yaml )
fi
cd cicd-manifests
git commit --allow-empty -m "Set image tag to ${SERVICE} ${TAG}"
git pull --rebase origin main
git push origin main --force