Skip to content

Commit

Permalink
Update image-build workflow (#88)
Browse files Browse the repository at this point in the history
Update image-build.yml (#92)

Update image-build.yml (#91)

Update tag-and-release.yml (#90)

Update image-build.yml (#89)
  • Loading branch information
georgepstaylor committed Nov 12, 2024
1 parent 04883c4 commit ff0821a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
25 changes: 9 additions & 16 deletions .github/workflows/image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,15 @@ jobs:
- name: Create safe tag for image
id: safe_tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "SAFE_TAG=$(echo ${{ github.event.pull_request.head.ref }} | sed 's/[^a-zA-Z0-9.]/-/g')-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
if [ "${{ inputs.tag }}" != "" ]; then
echo "Tag input exists: ${{ inputs.tag }}"
echo "SAFE_TAG=$(echo ${{ inputs.tag }} | sed 's/[^a-zA-Z0-9.]/-/g')" >> $GITHUB_OUTPUT
else
echo "SAFE_TAG=$(echo ${{ inputs.tag }} | sed 's/[^a-zA-Z0-9.]/-/g')" >> $GITHUB_OUTPUT
fi
- name: Output VERSION_REF
id: output_version_ref
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
# if on a PR we need to get the current branch name
echo "VERSION_REF=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
else
echo "VERSION_REF=${{ inputs.tag }}" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" == "pull_request" ] && [ "${{ github.event.pull_request.head.ref }}" != "main" ]; then
echo "SAFE_TAG=$(echo ${{ github.event.pull_request.head.ref }} | sed 's/[^a-zA-Z0-9.]/-/g')-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
else
echo "SAFE_TAG=$(echo ${{ inputs.tag }} | sed 's/[^a-zA-Z0-9.]/-/g')" >> $GITHUB_OUTPUT
fi
fi
- name: Set up Docker Buildx
Expand All @@ -73,15 +68,13 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/ministryofjustice/hmpps-ldap-automation:${{ steps.safe_tag.outputs.SAFE_TAG }}
build-args: |
VERSION_REF=${{ steps.output_version_ref.outputs.VERSION_REF }}

- name: Comment image tag on PR
env:
GH_TOKEN: ${{ github.token }}
if: github.event_name == 'pull_request'
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "Image built and pushed to ghcr.io/ministryofjustice/hmpps-ldap-automation:${{ steps.safe_tag.outputs.SAFE_TAG }}"
gh pr comment ${{ github.event.pull_request.number }} --body "Image built and pushed to `ghcr.io/ministryofjustice/hmpps-ldap-automation:${{ steps.safe_tag.outputs.SAFE_TAG }}`"
- name: Slack failure notification
if: ${{ failure() }}
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/tag-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ on:
- closed
branches:
- main
paths-ignore:
- "readme.md"
- ".gitignore"
- ".gitattributes"
- ".vscode/**"
- ".idea/**"
- ".github/**"

jobs:
release:
Expand Down

0 comments on commit ff0821a

Please sign in to comment.