Skip to content

Merge pull request #556 from openinfradev/harbor_test #752

Merge pull request #556 from openinfradev/harbor_test

Merge pull request #556 from openinfradev/harbor_test #752

name: Build And Deploy
on:
push:
branches:
- main
- develop
- release
workflow_dispatch:
env:
SERVICE: tks-api
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 "tks@github.com"
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