Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/build-and-push-to-ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Docker image build and publish to AWS ECR
on:
workflow_call:
inputs:
ecr_repo:
description: The name of the repository the image will be pushed to.
type: string
required: true
image_tags:
description: Tags to apply to images. Multiple tags can be provided in a comma separated format
type: string
required: true

env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: github-standards-hooks

jobs:
docker-build-and-push:
concurrency:
Expand All @@ -31,15 +31,15 @@ jobs:
role-to-assume: ${{ secrets.oidc_iam_role }}
aws-region: eu-west-2

- name: Check that the repository exists
env:
ECR_REPOSITORY: ${{ inputs.ecr_repo }}
run: |
if [[ -z `aws ecr describe-repositories | jq -r ".repositories.[] | .repositoryName" | grep $ECR_REPOSITORY` ]]; then
aws ecr create-repository --repository-name $ECR_REPOSITORY
else
echo "Repository exists."
fi
# - name: Check that the repository exists
# env:
# ECR_REPOSITORY: ${{ inputs.ecr_repo }}
# run: |
# if [[ -z `aws ecr describe-repositories | jq -r ".repositories.[] | .repositoryName" | grep $ECR_REPOSITORY` ]]; then
# aws ecr create-repository --repository-name $ECR_REPOSITORY
# else
# echo "Repository exists."
# fi

- name: Login to Amazon ECR
id: login-ecr
Expand All @@ -54,7 +54,7 @@ jobs:
read -ra tags <<<${{ inputs.image_tags }}
for tag in "${tags[@]}"
do
TAG_COMMAND="$TAG_COMMAND ${{ steps.login-ecr.outputs.registry }}/${{ inputs.ecr_repo }}:$tag"
TAG_COMMAND="$TAG_COMMAND ${{ steps.login-ecr.outputs.registry }}/${{ env.REGISTRY }}:$tag,"
done
echo "tags=$TAG_COMMAND" >> $GITHUB_OUTPUT

Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/test-build-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test Automated Release to ECR

on:
workflow_dispatch:
push:
branches-ignore:
- main

env:
REGISTRY: github-standards-hooks

jobs:
verify-release-version:
runs-on: ubuntu-latest
permissions:
contents: read

outputs:
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
requires_release: ${{ steps.version.outputs.requires_release }}

steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Python
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
with:
python-version-file: ".python-version"

- name: Extract version
id: extract_version
shell: python
run: |
import os
import tomllib
with open("pyproject.toml", "rb") as f:
contents = tomllib.load(f)
version = contents["project"]["version"]
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
fh.write(f"version={version}\n")

- name: Process version and tag
id: version
shell: bash
run: |
input_version="${{ steps.extract_version.outputs.version }}"
clean_version=${input_version#v}

# Validate version format
if ! echo "$clean_version" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Error: Version must be in format x.x.x (with or without v prefix)"
exit 1
fi

git_tag="v$clean_version"
requires_release="true"

# Check if tag already exists
if [ $(git tag -l "$git_tag") ]; then
echo "Tag $git_tag already exists"
requires_release="false"
fi

echo "version=$clean_version" >> $GITHUB_OUTPUT
echo "tag=$git_tag" >> $GITHUB_OUTPUT
echo "requires_release=$requires_release" >> $GITHUB_OUTPUT
echo "Clean version: $clean_version"
echo "Git tag: $git_tag"
echo "Requires release: $requires_release"

# This is a workaround to allow us to pass variables to the push-to-ecr reusable workflow. As that workflow runs in
# a separate github runner, the env vars in this file are not available
setup:
needs: [verify-release-version]
if: ${{ needs.verify-release-version.outputs.requires_release == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
REGISTRY: ${{ env.REGISTRY }}
steps:
- run: echo "All set!"

build-and-push-latest-image:
needs: [setup, verify-release-version]
permissions:
contents: read
id-token: write
packages: write
attestations: write
uses: ./.github/workflows/build-and-push-to-ecr.yml
with:
image_tags: poc1,poc2
secrets: inherit
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"anyio>=4.12.0",
"aiohttp>=3.13.2",
]
version = "v1.3.1"
version = "v1.4.0"

[project.scripts]
hooks-cli = "src.hooks.cli:main"
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading