Fix CI workflow: add Docker installation step
All checks were successful
Build And Test / build-and-push (push) Successful in 2m30s
All checks were successful
Build And Test / build-and-push (push) Successful in 2m30s
- Match workflow format with other projects - Add Docker installation step for Gitea Actions runner - Use correct secrets names (DOCKER_ID, DOCKER_PW, ACTION_TOKEN) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
81
.github/workflows/build.yaml
vendored
81
.github/workflows/build.yaml
vendored
@ -1,48 +1,69 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build And Test
|
||||||
|
|
||||||
|
run-name: ${{ gitea.actor }} is runs ci pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ "main" ]
|
||||||
- main
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches: [ "main" ]
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source code
|
- name: checkout source code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get version
|
- name: Retrieve version
|
||||||
id: version
|
id: img-ver
|
||||||
run: echo "VERSION=$(cat version)" >> $GITHUB_OUTPUT
|
uses: juliangruber/read-file-action@v1
|
||||||
|
with:
|
||||||
|
path: ./version
|
||||||
|
|
||||||
|
- name: Install 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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
- name: Login to Harbor Registry
|
- name: Login to Registry
|
||||||
uses: docker/login-action@v3
|
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-nhn:${{ steps.img-ver.outputs.content }} .
|
||||||
|
|
||||||
|
- name: Push to Docker
|
||||||
|
run: docker push harbor.icurfer.com/msa-demo/msa-django-nhn:${{ steps.img-ver.outputs.content }}
|
||||||
|
|
||||||
|
## pre cd
|
||||||
|
- name: Setup Kustomize
|
||||||
|
uses: yokawasa/action-setup-kube-tools@v0.9.2
|
||||||
with:
|
with:
|
||||||
registry: harbor.icurfer.com
|
kustomize: "3.7.0"
|
||||||
username: ${{ secrets.HARBOR_USERNAME }}
|
|
||||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Checkout kustomize repository
|
||||||
uses: docker/build-push-action@v5
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
repository: "dev/cd-msa-django-nhn"
|
||||||
push: true
|
ref: main
|
||||||
tags: harbor.icurfer.com/msa-demo/msa-django-nhn:${{ steps.version.outputs.VERSION }}
|
token: ${{ secrets.ACTION_TOKEN }}
|
||||||
|
path: cd-msa-django-nhn
|
||||||
|
|
||||||
- name: Update Kubernetes manifests
|
- name: Update Kubernetes resources
|
||||||
|
run: |
|
||||||
|
cd cd-msa-django-nhn/overlays/dev/
|
||||||
|
kustomize edit set image harbor.icurfer.com/msa-demo/msa-django-nhn:${{ steps.img-ver.outputs.content }}
|
||||||
|
cat kustomization.yaml
|
||||||
|
|
||||||
|
## cd commit
|
||||||
|
- name: Commit files
|
||||||
run: |
|
run: |
|
||||||
git clone https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository_owner }}/cd-msa-django-nhn.git
|
|
||||||
cd cd-msa-django-nhn
|
cd cd-msa-django-nhn
|
||||||
sed -i "s|harbor.icurfer.com/msa-demo/msa-django-nhn:.*|harbor.icurfer.com/msa-demo/msa-django-nhn:${{ steps.version.outputs.VERSION }}|g" kustomize/overlays/dev/kustomization.yaml
|
git config --global user.email "icurfer@gmail.com"
|
||||||
git config user.name "GitHub Actions"
|
git config --global user.name "icurfer"
|
||||||
git config user.email "actions@github.com"
|
git commit -am "Update image tag"
|
||||||
git add .
|
git push -u origin main
|
||||||
git commit -m "Update image tag to ${{ steps.version.outputs.VERSION }}" || echo "No changes to commit"
|
|
||||||
git push
|
|
||||||
|
|||||||
Reference in New Issue
Block a user