2024-11-10 12:42:58 +01:00

42 lines
1.4 KiB
YAML

name: BuildAndPushImageOnHarborAndUpdateArgoCDConfig
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: docker/login-action@v1
with:
registry: harbor.example.com
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- uses: actions/checkout@v3
- name: BuildAndPushImageOnHarbor
run: |
docker build ./ -t harbor.example.com/chaturmail/chaturmail-backend:${{ github.run_number }}
docker push harbor.example.com/chaturmail/chaturmail-backend:${{ github.run_number }}
- name: Clone Repository
run: |
git clone <argocd-config-repo-url>
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod a+x /usr/local/bin/yq
- name: Update YAML File
run: |
yq -i '.spec.template.spec.containers[0].image = "harbor.example.com/chaturmail/chaturmail-backend:${{ github.run_number }}"' 'argocd-configs/chaturmail-pod.yaml'
- name: Push to Repo
run: |
git config --global user.name "${{secrets.USERNAME_GITHUB}}"
git config --global user.email "${{secrets.EMAIL_GITHUB}}"
cd argocd-test-configs
git add .
git commit -m "Updated by GitHub Actions"
git push <argocd-config-repo-url> --all