Files
johannes.gasser 2a0f7d5bcf
Build and Deploy / build-and-deploy (push) Failing after 2m42s
add missing files
2026-05-07 09:46:44 +02:00

60 lines
1.9 KiB
YAML

name: Build and Deploy
on:
push:
branches:
- main
env:
REGISTRY: git.idealconnected.com
ORG: johannes.gasser
APP: theater-ziefen
GITOPS_REPO: cloud-hosting
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set image tag
id: tag
run: echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
- name: Log in to Gitea container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ gitea.actor }}
password: ${{ secrets.CI_TOKEN }}
- name: Build and push frontend image
uses: docker/build-push-action@v5
with:
context: .
target: frontend
push: true
tags: |
${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.APP }}:${{ steps.tag.outputs.sha }}
${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.APP }}:latest
- name: Update image tags in gitops repo
env:
CI_TOKEN: ${{ secrets.CI_TOKEN }}
SHA: ${{ steps.tag.outputs.sha }}
run: |
git config --global user.email "ci@idealconnected.com"
git config --global user.name "Gitea CI"
git clone \
"https://${{ gitea.actor }}:${CI_TOKEN}@${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.GITOPS_REPO }}.git" \
/tmp/gitops
cd /tmp/gitops
sed -i \
"s|image: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.APP }}:.*|image: ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.APP }}:${SHA}|" \
"apps/${{ env.APP }}/deployment.yaml"
git add "apps/${{ env.APP }}/deployment.yaml"
git diff --cached --quiet && echo "No changes, skipping commit." && exit 0
git commit -m "ci: update ${{ env.APP }} to ${SHA}"
git push origin main