All checks were successful
Build And Test / build-and-push (push) Successful in 7s
95 lines
2.9 KiB
YAML
95 lines
2.9 KiB
YAML
name: Build And Test
|
|
|
|
run-name: ${{ gitea.actor }} is runs ci pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
# paths-ignore:
|
|
# - LICENCE
|
|
# - 'docs/**'
|
|
# - 'helm/**'
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout source code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Retrieve version # tag version
|
|
id: img-ver
|
|
uses: juliangruber/read-file-action@v1
|
|
with:
|
|
path: ./version
|
|
#test
|
|
# - name: Install Docker // Docker 설치
|
|
# run: |
|
|
# curl -fsSL https://get.docker.com -o get-docker.sh
|
|
# sh get-docker.sh
|
|
# if: runner.os == 'Linux'
|
|
|
|
# - name: Set up Docker Buildx
|
|
# # uses: https://github.com/docker/setup-buildx-action@v1
|
|
# uses: docker/setup-buildx-action@v1
|
|
|
|
# - name: Login to Registry
|
|
# run: docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PW }} https://harbor.icurfer.com
|
|
|
|
# - name: build
|
|
# run: docker build -t harbor.icurfer.com/msa-demo/msa-django-ansible:${{ steps.img-ver.outputs.content }} .
|
|
|
|
# - name: Push to Docker
|
|
# run: docker push harbor.icurfer.com/msa-demo/msa-django-ansible:${{ steps.img-ver.outputs.content }}
|
|
#test
|
|
## pre cd
|
|
- name: Setup Kustomize
|
|
uses: yokawasa/action-setup-kube-tools@v0.9.2
|
|
with:
|
|
kustomize: "3.7.0"
|
|
|
|
- name: Checkout kustomize repository
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: "dev/cd-msa-django-ansible"
|
|
ref: main
|
|
token: ${{ secrets.ACTION_TOKEN }}
|
|
path: cd-msa-django-ansible
|
|
|
|
- name: Update container image Tag
|
|
run: |
|
|
cd cd-msa-django-ansible/overlays/dev/
|
|
kustomize edit set image harbor.icurfer.com/msa-demo/msa-django-ansible:${{ steps.img-ver.outputs.content }}
|
|
cat kustomization.yaml
|
|
|
|
- name: Update container name
|
|
run: |
|
|
cd cd-msa-django-ansible/overlays/dev/
|
|
|
|
echo "✅ Installing yq..."
|
|
wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64
|
|
chmod +x /usr/local/bin/yq
|
|
|
|
export VERSION="${{ steps.img-ver.outputs.content }}"
|
|
export VERSION_SAFE="${VERSION//./d}"
|
|
|
|
echo "✅ Safely updating container name in patch-deployment.yaml..."
|
|
# 이 방식은 containers 배열의 첫번째 요소 안의 name만 수정하고 image는 유지함
|
|
yq e -i '
|
|
(.spec.template.spec.containers[0].name) = "msa-django-ansible-" + strenv(VERSION_SAFE)
|
|
' patch-deployment.yaml
|
|
|
|
echo "✅ Final patch-deployment.yaml content:"
|
|
cat patch-deployment.yaml
|
|
|
|
|
|
## cd commit
|
|
- name: Commit files
|
|
run: |
|
|
cd cd-msa-django-ansible
|
|
git config --global user.email "icurfer@gmail.com"
|
|
git config --global user.name "icurfer"
|
|
git commit -am "Update image tag"
|
|
git push -u origin main |