Skip to content

Release service

Release service #20

name: Release service
on:
workflow_dispatch:
inputs:
service_name:
description: 'Service name'
required: true
type: choice
options:
- a
- b
automatic_deploy_to_dev:
description: "Automatically deploy this release to DEV environment"
type: boolean
workflow_call:
inputs:
service_name:
required: true
type: string
automatic_deploy_to_dev:
type: boolean
jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/${{ inputs.service_name }}/
outputs:
next_tag: ${{ steps.tag_image.outputs.next_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Check for successful tests
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if the github ref has a successful test status
if ! gh api repos/${{ github.repository }}/commits/${{ github.ref }}/check-runs | jq '.check_runs[] | select(.conclusion == "success")' > /dev/null; then
echo "No successful tests found for ${{ github.ref }}"
exit 1
fi
- name: Build docker image
run: make build
- name: Tag the docker image
id: tag_image
run: PRERELEASE=${{ github.event_name == 'workflow_dispatch' }} make release
- uses: thejeff77/[email protected]
with:
tag: ${{ steps.tag_image.outputs.next_tag }}
message: '"${{ steps.tag_image.outputs.next_tag }}: PR #${{ github.event.pull_request.number }} - ${{ github.event.pull_request.title }}"'
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_image.outputs.next_tag }}
generate_release_notes: true
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
automatic_deploy:
if: ${{ inputs.automatic_deploy_to_dev == true }}
needs: release
uses: ./.github/workflows/deploy.yaml
with:
checkout_ref: ${{ needs.release.outputs.next_tag }}
service_name: ${{ inputs.service_name }}
environment: dev