Some checks failed
Build (develop) / Promote (main) / build-and-push-deploy (push) Failing after 1m15s
43 lines
1.5 KiB
YAML
43 lines
1.5 KiB
YAML
name: Build (develop) / Promote (main)
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-push-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Build and Push
|
|
run: |
|
|
REGISTRY="git.simplifiquehc.com.br"
|
|
IMAGE_NAME="$REGISTRY/simplifique/vendaweb-api"
|
|
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
|
|
|
echo "${{ secrets.K8S }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
|
|
|
|
docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" .
|
|
docker push "$IMAGE_NAME:$SHA_TAG"
|
|
docker push "$IMAGE_NAME:latest"
|
|
|
|
- name: Update Manifest and Push to Git
|
|
run: |
|
|
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
|
IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api"
|
|
|
|
# 1. Altera a imagem no arquivo YAML (ajuste o caminho 'deploy-api.yaml' se necessário)
|
|
# O comando procura a linha 'image:' e substitui pela nova tag do SHA
|
|
sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" deploy-api.yaml
|
|
|
|
# 2. Configura o Git para commitar a alteração
|
|
git config --global user.name "Gitea Action"
|
|
git config --global user.email "actions@simplifiquehc.com.br"
|
|
|
|
# 3. Faz o commit e push da alteração no manifesto
|
|
git add deploy-api.yaml
|
|
git commit -m "chore: update image tag to $SHA_TAG [skip ci]"
|
|
git push origin main |