Skip to content

chore(github-workflow): trying different digest #14

chore(github-workflow): trying different digest

chore(github-workflow): trying different digest #14

Workflow file for this run

# https://github.com/EPFL-ENAC/epfl-enac-deploy-action#readme
name: build-push-dev
"on":
push:
branches:
- dev
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{github.repository}}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- Dockerfile: ./Dockerfile
context: ./
image: ghcr.io/epfl-enac/sxl-recrete-atlas-frontend
permissions:
contents: read
packages: write
outputs:
output1: ${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
- name: Setup output
id: output
run: echo "{name}={value}" >> $GITHUB_OUTPUT \
&& echo "digest=${{ github.sha }}" >> $GITHUB_OUTPUT \
&& echo "digest-${{matrix.shardIndex}}=${{ github.sha }}" >> $GITHUB_OUTPUT \
&& echo "tags=${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT \
&& echo "labels=${{ steps.meta.outputs.labels }}" >> $GITHUB_OUTPUT
- name: Build and push Docker image EPFL-ENAC.Agent.Service
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: true
file: ${{ matrix.dockerfile }}
tags: ${{ steps.meta.outputs.tags }},${{ matrix.image }}:${{ github.sha }},${{ matrix.image }}:latest
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: build-and-push-image
runs-on: ubuntu-latest
steps:
# This is used to trigger the correct github CI pipeline:
# push to main: update dev deployment
# push a tag: update stage, trigger prod merge req.
- name: Deploy application to dev
if: ${{ github.ref }} == "refs/heads/dev"
run: |
echo "Deploying to prod" && \
echo "Digest: ${{ toJson(needs.build-and-push-image) }}" && \
curl -X POST \
-H "Authorization: Bearer ${{ secrets.CD_TOKEN }}" \
${{ secrets.CD_URI }} \
-d '{
"event_type": "update-manifest",
"client_payload": {
"digest": "${{ toJson(needs.build-and-push-image.outputs) }}",
"repo_name": "${{ secrets.CD_REPO }}",
"repo_org": "${{ secrets.CD_ORG }}",
"branch": "dev"
}
}'
- name: Deploy to prod rules (defined in CD pipeline)
if: startsWith(github.ref, 'refs/tags/')
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.CD_TOKEN }}" \
${{ secrets.CD_URI }} \
-d '{
"event_type": "update-manifest",
"client_payload": {
"digest": "${{ toJson(needs.build-and-push-image.outputs.digest) }}",
"repo_name": "${{ secrets.CD_REPO }}",
"repo_org": "${{ secrets.CD_ORG }}",
"branch": "prod"
}
}'