From 5b242f0f4e772a5f5d30b864dd8b4767e6fd6b14 Mon Sep 17 00:00:00 2001 From: Niall Thomson Date: Fri, 7 Mar 2025 03:14:37 +0000 Subject: [PATCH] Change --- .../workflows/{arch.yaml => artifacts.yaml} | 55 +++++++++++++++---- .github/workflows/publish-build.yml | 36 +++--------- 2 files changed, 50 insertions(+), 41 deletions(-) rename .github/workflows/{arch.yaml => artifacts.yaml} (55%) diff --git a/.github/workflows/arch.yaml b/.github/workflows/artifacts.yaml similarity index 55% rename from .github/workflows/arch.yaml rename to .github/workflows/artifacts.yaml index 89abd6784..a249f962d 100644 --- a/.github/workflows/arch.yaml +++ b/.github/workflows/artifacts.yaml @@ -1,16 +1,19 @@ -name: Arch Test +name: Publish Artifacts on: - workflow_dispatch: + workflow_call: + inputs: + version: + type: string + default: "-" permissions: contents: write - pull-requests: write id-token: write jobs: - docker: - name: Docker E2E Tests + build: + name: Build Images runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -22,6 +25,8 @@ jobs: arch: arm64 steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.version }} - name: "Setup Docker" uses: ./.github/actions/setup-docker - name: "Setup Env" @@ -38,23 +43,32 @@ jobs: uses: aws-actions/amazon-ecr-login@v2 with: registry-type: public - - name: Test + + - name: Build shell: devenv shell bash -- -e {0} env: + TAG_NAME: ${{ inputs.version }} TARGET_ARCH: ${{ matrix.arch }} AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} run: | - # Build first to prevent partial container set push - yarn nx run-many -t container --projects=tag:service --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-{projectName}:arch4-${TARGET_ARCH} + export IMAGE_TAG=${TAG_NAME#v} # Build first to prevent partial container set push - yarn nx run-many -t container --push true --projects=tag:service --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-{projectName}:arch4-${TARGET_ARCH} + yarn nx run-many -t container --projects=tag:service --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-{projectName}:${IMAGE_TAG}-${TARGET_ARCH} + yarn nx container load-generator --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-utils:load-gen.${IMAGE_TAG} + + # Then push + yarn nx run-many -t container --push true --projects=tag:service --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-{projectName}:${IMAGE_TAG}-${TARGET_ARCH} + yarn nx container load-generator --push true --tags ${AWS_ECR_REPOSITORY}/retail-store-sample-utils:load-gen.${IMAGE_TAG} - manifest: - needs: docker + publish: + name: Publish + needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + ref: ${{ inputs.version }} - name: "Setup Env" uses: ./.github/actions/setup-env - name: "Get AWS credentials" @@ -72,5 +86,22 @@ jobs: - name: Push manifests shell: devenv shell bash -- -e {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_NAME: ${{ inputs.version }} + AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }} run: | - yarn nx run-many -t manifest --projects=tag:service --args="--repository=public.ecr.aws/t0t9x2q2/retail-store-sample-{projectName},--tag=arch4" + export IMAGE_TAG=${TAG_NAME#v} + + yarn nx run-many -t manifest --projects=tag:service --args="--repository=${AWS_ECR_REPOSITORY}/retail-store-sample-{projectName},--tag=${IMAGE_TAG}" + yarn nx manifest load-generator --args="--repository=${AWS_ECR_REPOSITORY}/retail-store-sample-utils,--tag=load-gen.${IMAGE_TAG}" + + yarn nx run-many -t helm --projects=tag:service --remote oci://${AWS_ECR_REPOSITORY} --push + + bash scripts/compose-dist.sh + + gh release upload ${TAG_NAME} ./dist/docker-compose/docker-compose.yaml --clobber + + bash scripts/kubernetes-dist.sh + + gh release upload ${TAG_NAME} ./dist/kubernetes/kubernetes.yaml --clobber diff --git a/.github/workflows/publish-build.yml b/.github/workflows/publish-build.yml index 6520c7dcb..081a90d22 100644 --- a/.github/workflows/publish-build.yml +++ b/.github/workflows/publish-build.yml @@ -3,39 +3,17 @@ name: Publish Artifacts on: workflow_dispatch: inputs: - tag: - description: "Tag" + version: + description: "Version" required: true permissions: id-token: write contents: write - pull-requests: write jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: "Get AWS credentials" - uses: aws-actions/configure-aws-credentials@v1 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: us-east-1 - role-session-name: GithubActionsSession - - - name: "Login to Amazon ECR Public" - id: login-ecr-public - uses: aws-actions/amazon-ecr-login@v2 - with: - registry-type: public - - - uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag }} - - - name: "Publish artifacts" - uses: ./.github/actions/publish-artifacts - with: - tag: ${{ inputs.tag }} - ecr-repository: ${{ secrets.AWS_ECR_REPOSITORY }} - gh-token: ${{ secrets.GITHUB_TOKEN }} + artifacts: + uses: ./.github/workflows/artifacts.yaml + with: + version: ${{ inputs.version }} + secrets: inherit