This repository has been archived by the owner on Oct 13, 2024. It is now read-only.
frontend-deploy #138
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: frontend-deploy | |
on: | |
workflow_run: | |
workflows: ['frontend-ci'] | |
branches: [main] | |
types: | |
- completed | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
pack: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
name: Build and push Docker image | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3.1.0 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5.5.1 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v5.3.0 | |
with: | |
context: ./frontend | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
COMMIT_HASH=${{ github.sha }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1.1.1 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: pack | |
steps: | |
- name: Trigger deployment | |
run: | | |
curl -H "Authorization: Bearer ${{ secrets.FRONTEND_WATCHTOWER_TOKEN }}" https://watchtower.cacic.dev.br/fctapp/v1/update > /dev/null |