38 lines
1.4 KiB
YAML
38 lines
1.4 KiB
YAML
name: Build and Push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Harbor
|
|
run: |
|
|
echo '${{ secrets.HARBOR_TOKEN }}' | docker login harbor.mxhunt.in -u '${{ secrets.HARBOR_USERNAME }}' --password-stdin
|
|
|
|
- name: Build and Push Docker image
|
|
run: |
|
|
IMAGE=harbor.mxhunt.in/${{ vars.HARBOR_PROJECT }}/payment-api:${{ gitea.sha }}
|
|
docker build -t $IMAGE .
|
|
docker push $IMAGE
|
|
docker tag $IMAGE harbor.mxhunt.in/${{ vars.HARBOR_PROJECT }}/payment-api:latest
|
|
docker push harbor.mxhunt.in/${{ vars.HARBOR_PROJECT }}/payment-api:latest
|
|
echo "Pushed: $IMAGE"
|
|
|
|
- name: Update deployments repo
|
|
run: |
|
|
git clone https://gitea-actions:${{ secrets.DEPLOY_TOKEN }}@git.mxhunt.in/${{ gitea.repository_owner }}/deployments.git
|
|
cd deployments
|
|
sed -i "s|image: .*/payment-api:.*|image: harbor.mxhunt.in/${{ vars.HARBOR_PROJECT }}/payment-api:${{ gitea.sha }}|" payment-api/deployment.yaml
|
|
git config user.name "gitea-actions"
|
|
git config user.email "gitea-actions@localhost"
|
|
git add payment-api/deployment.yaml
|
|
git diff --cached --quiet || git commit -m "chore: update payment-api image to ${{ gitea.sha }}"
|
|
git push || (git pull --rebase && git push)
|