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:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
- name: checkout source code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Get version
|
||||
id: version
|
||||
run: echo "VERSION=$(cat version)" >> $GITHUB_OUTPUT
|
||||
- name: Retrieve version
|
||||
id: img-ver
|
||||
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
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to Harbor Registry
|
||||
uses: docker/login-action@v3
|
||||
- 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-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:
|
||||
registry: harbor.icurfer.com
|
||||
username: ${{ secrets.HARBOR_USERNAME }}
|
||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||
kustomize: "3.7.0"
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
- name: Checkout kustomize repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: harbor.icurfer.com/msa-demo/msa-django-nhn:${{ steps.version.outputs.VERSION }}
|
||||
repository: "dev/cd-msa-django-nhn"
|
||||
ref: main
|
||||
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: |
|
||||
git clone https://${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_TOKEN }}@github.com/${{ github.repository_owner }}/cd-msa-django-nhn.git
|
||||
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 user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git add .
|
||||
git commit -m "Update image tag to ${{ steps.version.outputs.VERSION }}" || echo "No changes to commit"
|
||||
git push
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user