From 378658aeb886db98049b902764cfd17315632d93 Mon Sep 17 00:00:00 2001 From: Chris Hopkins Date: Fri, 20 Feb 2026 15:22:01 +0000 Subject: [PATCH] wip test out new pipeline Signed-off-by: DBT pre-commit check --- .github/workflows/build-and-push-to-ecr.yml | 28 +++--- .github/workflows/test-build-workflow.yml | 99 +++++++++++++++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/test-build-workflow.yml diff --git a/.github/workflows/build-and-push-to-ecr.yml b/.github/workflows/build-and-push-to-ecr.yml index 22ff6834..03040511 100644 --- a/.github/workflows/build-and-push-to-ecr.yml +++ b/.github/workflows/build-and-push-to-ecr.yml @@ -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: @@ -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 @@ -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 diff --git a/.github/workflows/test-build-workflow.yml b/.github/workflows/test-build-workflow.yml new file mode 100644 index 00000000..f11c413d --- /dev/null +++ b/.github/workflows/test-build-workflow.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 82931aad..f075a208 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,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" diff --git a/uv.lock b/uv.lock index dd993c31..64d2102c 100644 --- a/uv.lock +++ b/uv.lock @@ -480,7 +480,7 @@ wheels = [ [[package]] name = "github-standards" -version = "1.3.1" +version = "1.4.0" source = { editable = "." } dependencies = [ { name = "aiohttp" },