Skip to content

Split generate version into separate job to test passing the value (#19) #51

Split generate version into separate job to test passing the value (#19)

Split generate version into separate job to test passing the value (#19) #51

Workflow file for this run

name: Main
on:
push:
branches: ["main"]
# Ensure only one instance of the workflow is running at a time.
# This helps with race conditions when upserting releases.
concurrency:
group: "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
generate-version:
name: "Generate Version"
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ steps.generate-version.outputs.RELEASE_VERSION }}
steps:
- name: Generate version based on date
id: generate-version
run: echo "RELEASE_VERSION=$(date '+%Y-%m-%d_%H_%M')" >> $GITHUB_OUTPUT
deploy-staging:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write # Write is required to create/update releases AND to write tags
needs: generate-version
environment: staging
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-version.outputs.RELEASE_VERSION }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging
build-args: |
APP_VERSION=${{ needs.generate-version.outputs.RELEASE_VERSION }}
- name: Create release
uses: abusix/github-release-actions/[email protected]
with:
release-version: ${{ needs.generate-version.outputs.RELEASE_VERSION }}
github-token: ${{ secrets.GITHUB_TOKEN }}