Skip to content

Merge pull request #196 from ministryofjustice/IjazMoJ-patch-1 #45

Merge pull request #196 from ministryofjustice/IjazMoJ-patch-1

Merge pull request #196 from ministryofjustice/IjazMoJ-patch-1 #45

name: LDAP Automation Image Build
on:
workflow_dispatch:
push:
branches:
- main
paths:
- docker/ldap-automation/**
- .github/workflows/ldap-*.yml
permissions:
packages: write
contents: write
jobs:
build-and-push:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version and push tag
id: BumpVersionAndPushTag
uses: anothrNick/github-tag-action@1.62.0 # Don't use @master unless you're happy to test the latest version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: minor # Making this default visible
INITIAL_VERSION: 0.0.0 # Making this default visible
TAG_CONTEXT: repo # Making this default visible
PRERELEASE: true
PRERELEASE_SUFFIX: ${{ github.ref_name }} # Branch name
DRY_RUN: ${{ github.ref != 'refs/heads/main' }} # Tag repo on main, not otherwise. Note we can still use the proposed dry-run tag to tag ECR images
- name: Create safe tag
id: safe_tag
run: |
echo "SAFE_TAG=$(echo ${{ steps.BumpVersionAndPushTag.outputs.new_tag }} | sed 's/[^a-zA-Z0-9.]/-/g')" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
id: setup_buildx
uses: docker/setup-buildx-action@v3
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push to ghcr
id: build_publish
uses: docker/build-push-action@v5
with:
context: ./docker/ldap-automation
file: ./docker/ldap-automation/Dockerfile
platforms: linux/amd64
push: true
tags: ghcr.io/ministryofjustice/hmpps-ldap-automation:${{ steps.safe_tag.outputs.SAFE_TAG }}