Skip to content

v0.0.28

v0.0.28 #12

Workflow file for this run

name: Deploy on Release or Pre-release
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PROJECT_NAME: ahb-tabellen
OCTOPUS_SPACE: Default
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 "::set-output name=build_date::$BUILD_DATE"
echo "::set-output name=commit_id::$COMMIT_ID"
echo "::set-output name=version_tag::$VERSION_TAG"
echo "::set-output name=prerelease::${{ github.event.release.prerelease }}"
- name: Log in to the Container registry
uses: docker/login-action@v3.3.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.6.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6.10.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_DATE=${{ steps.build_release_info.outputs.build_date }}
COMMIT_ID=${{ steps.build_release_info.outputs.commit_id }}
VERSION=${{ steps.build_release_info.outputs.version_tag }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.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: ${{ steps.build_release_info.outputs.version_tag }}
git_ref: ${{ github.ref }}
git_commit: ${{ github.sha }}
release_notes: "Release created from GitHub Actions. Version: ${{ steps.build_release_info.outputs.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: ${{ steps.build_release_info.outputs.version_tag }}
environments: |
Staging
- name: Notify for Production Deployment Approval
if: ${{ steps.build_release_info.outputs.prerelease == 'false' }}
run: |
echo "Release ${{ steps.build_release_info.outputs.version_tag }} created. Awaiting manual approval for production deployment."