v0.0.39 #23
Workflow file for this run
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: Deploy on Release or Pre-release | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
PROJECT_NAME: ahb-tabellen | |
OCTOPUS_SPACE: Default | |
BUILD_DATE: "set by build_release_info step" | |
COMMIT_ID: "set by build_release_info step" | |
VERSION_TAG: "set by build_release_info step" | |
DOCKER_METADATA_OUTPUT_TAGS: "set by metadata action" | |
DOCKER_METADATA_OUTPUT_LABELS: "set by metadata action" | |
DIGEST: "set by output of push step" | |
on: | |
release: | |
types: [published] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set build and release information | |
id: build_release_info | |
run: | | |
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
COMMIT_ID=$(git rev-parse HEAD) | |
VERSION_TAG=${GITHUB_REF#refs/tags/} | |
echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
echo "COMMIT_ID=$COMMIT_ID" >> $GITHUB_ENV | |
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }} | |
labels: ${{ env.DOCKER_METADATA_OUTPUT_LABELS }} | |
build-args: | | |
BUILD_DATE=${{ env.BUILD_DATE }} | |
COMMIT_ID=${{ env.COMMIT_ID }} | |
VERSION=${{ env.VERSION_TAG }} | |
# The build-push-action does not output the digest as environment variable only as output. | |
# But the output way is deprecated. So we need to set it manually | |
# https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ | |
# I opened an issue in the build-push-action repository: https://github.com/docker/build-push-action/issues/1285 | |
- name: Set DIGEST environment variable | |
run: echo "DIGEST=${{ steps.push.outputs.digest }}" >> $GITHUB_ENV | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v2 | |
with: | |
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
subject-digest: ${{ env.DIGEST }} | |
push-to-registry: true | |
- name: Login to Octopus Deploy 🐙 | |
uses: OctopusDeploy/login@v1 | |
with: | |
server: https://hochfrequenz.octopus.app | |
service_account_id: 990f3f62-2e3f-4b1e-9569-d5a6817a2c80 | |
- name: Create a release in Octopus Deploy 🐙 | |
uses: OctopusDeploy/create-release-action@v3 | |
with: | |
space: ${{ env.OCTOPUS_SPACE }} | |
project: ${{ env.PROJECT_NAME }} | |
release_number: ${{ env.VERSION_TAG }} | |
git_ref: ${{ github.ref }} | |
git_commit: ${{ github.sha }} | |
release_notes: "Release created from GitHub Actions. Version: ${{ env.VERSION_TAG }}" | |
- name: Deploy a release in Octopus Deploy 🐙 | |
uses: OctopusDeploy/deploy-release-action@v3 | |
with: | |
space: ${{ env.OCTOPUS_SPACE }} | |
project: ${{ env.PROJECT_NAME }} | |
release_number: ${{ env.VERSION_TAG }} | |
environments: | | |
Staging | |
- name: Notify for Production Deployment Approval | |
if: ${{ github.event.release.prerelease == 'false' }} | |
run: | | |
echo "Release ${{ env.VERSION_TAG }} created. Awaiting manual approval for production deployment." |