Skip to content

Deployment

Deployment #8

Workflow file for this run

name: Deployment
on:
push:
branches:
- main
workflow_dispatch:
inputs:
environment:
description: "Select the environment to deploy"
required: true
type: choice
options:
- staging
- production
jobs:
define-environment:
runs-on: ubuntu-latest
outputs:
environments: ${{ steps.set-env.outputs.environments }}
steps:
- id: set-env
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]
then
echo "environments=[\"${{ github.event.inputs.environment }}\"]" >> "$GITHUB_OUTPUT"
else
echo 'environments=["staging", "production"]' >> "$GITHUB_OUTPUT"
fi
- run: echo ${{ steps.set-env.outputs.environments }} >> $GITHUB_STEP_SUMMARY
depoy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- define-environment
strategy:
matrix:
environment: ${{ fromJSON(needs.define-environment.outputs.environments) }}
environment: ${{ matrix.environment }}
env:
DOCKER_TAG: ${{ (matrix.environment) == 'production' && 'latest' || 'edge' }}
DOCKER_REGISTRY: ghcr.io
DOCKER_NAMESPACE: ${{ github.repository_owner }}
DOCKER_EXTRA_ARGS: --label org.opencontainers.image.source=https://github.com/${{ github.repository }} --cache-from type=gha,mode=max --cache-to type=gha,mode=max
steps:
- uses: actions/checkout@v4
- name: Log into registry ${{ env.DOCKER_REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./actions/infra-build-images
with:
registry: ${{ env.DOCKER_REGISTRY }}
namespace: ${{ env.DOCKER_NAMESPACE }}
docker-tag: ${{ env.DOCKER_TAG }}
extra-args: --push ${{ env.DOCKER_EXTRA_ARGS }}