Skip to content

Commit 9d83b4c

Browse files
committed
final version (fingers crossed)
1 parent 5283c3c commit 9d83b4c

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

.github/workflows/publish.yml

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,69 @@
1-
name: Publish image and deploy to staging
1+
name: Build image from main and deploy to staging
22

33
on:
44
push:
55
branches:
66
- main
77
workflow_dispatch:
88

9-
env:
10-
ECR_REPOSITORY_URI: ${{ secrets.AWS_ECR_ACCOUNT }}.dkr.ecr.eu-west-1.amazonaws.com/${{ secrets.ECR_REPOSITORY }}
11-
129
jobs:
1310
prepare-variables:
14-
name: Prepare variables
15-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
12+
timeout-minutes: 5
1613
permissions:
1714
contents: read
15+
1816
outputs:
19-
image_tags: ${{ steps.generate_image_tags.outputs.image_tags }}
20-
unique_image_tag: ${{ steps.generate_image_tags.outputs.unique_image_tag }}
21-
ecr_repo_uri: ${{ steps.generate_image_tags.outputs.ecr_repo_uri }}
17+
image_tag: ${{ steps.prepare-variables.outputs.IMAGE_TAG }}
18+
ecr_tags: ${{ steps.prepare-variables.outputs.ECR_TAGS }}
19+
2220
steps:
23-
# Required by generate_image_tags
24-
- name: Checkout
25-
uses: actions/checkout@v6
21+
# Required by prepare-variables
22+
- uses: actions/checkout@v6
2623

27-
- name: Generate image tags
28-
id: generate_image_tags
24+
- name: Prepare variables
25+
id: prepare-variables
2926
env:
30-
IMAGE_REPOSITORY: ${{ env.ECR_REPOSITORY_URI }}
31-
BRANCH_IMAGE_TAG: ${{ github.ref_name }}
27+
# github.ref_name is the plain (no prefix) branch or tag name that
28+
# triggered the workflow (e.g. "main", "v1.2.3").
29+
# We are passing it through env to prevent script injection via crafted
30+
# branch names (e.g. a branch named `; rm -rf /` would be interpolated
31+
# directly into the shell script if using ${{ }} inline).
32+
REF_NAME: ${{ github.ref_name }}
3233
run: |
33-
unique_image_tag="${BRANCH_IMAGE_TAG}-$(git rev-parse --short HEAD)"
34+
set -x
3435
35-
image_tags="${IMAGE_REPOSITORY}:${BRANCH_IMAGE_TAG},${IMAGE_REPOSITORY}:${unique_image_tag}"
36+
image_tag_unique="${REF_NAME}-$(git rev-parse --short HEAD)"
37+
ecr_tags="${image_tag_unique},${REF_NAME}-latest"
3638
37-
echo "unique_image_tag=${unique_image_tag}" >> $GITHUB_OUTPUT
38-
echo "image_tags=${image_tags}" >> $GITHUB_OUTPUT
39-
echo "ecr_repo_uri=${IMAGE_REPOSITORY}" >> $GITHUB_OUTPUT
39+
echo "IMAGE_TAG=${image_tag_unique}" >> $GITHUB_OUTPUT
40+
echo "ECR_TAGS=${ecr_tags}" >> $GITHUB_OUTPUT
4041
4142
4243
build-push:
43-
needs: prepare-variables
44-
uses: saleor/saleor-internal-actions/.github/workflows/build-push-image-multi-platform.yaml@92c29aa0e4545de579b892b2ef9f2d6366c29c11 # v1.5.2
44+
needs: [prepare-variables]
45+
uses: saleor/saleor-internal-actions/.github/workflows/build-push-image-multi-platform.yaml@9c7a814c011945f26f0aa1191fc9c62de45477c2 # v1.7.0
46+
4547
permissions:
4648
contents: read
4749
id-token: write # needed for AWS/ECR login
4850
packages: write # needed for GHCR (not used, but required permission)
49-
with:
50-
checkout-ref: ${{ github.ref_name }}
5151

52+
with:
53+
tags: ${{ needs.prepare-variables.outputs.ecr_tags }}
5254
enable-aws-ecr: true
5355
aws-ecr-region: eu-west-1
54-
oci-full-repository: ${{ needs.prepare-variables.outputs.ecr_repo_uri }}
55-
tags: ${{ needs.prepare-variables.outputs.image_tags }}
56-
57-
amd64-runner-image: ubuntu-24.04
58-
arm64-runner-image: ubuntu-24.04-arm
5956

6057
secrets:
58+
oci-full-repository: ${{ secrets.AWS_ECR_ACCOUNT }}.dkr.ecr.eu-west-1.amazonaws.com/${{ secrets.ECR_REPOSITORY }}
6159
aws-ecr-role-to-assume: arn:aws:iam::${{ secrets.AWS_STAGING_ACCOUNT_ID }}:role/${{ secrets.AWS_APPS_SALEOR_MCP_STAGING_CICD_ROLE_NAME }}
6260
aws-ecr-registries: ${{ secrets.AWS_ECR_ACCOUNT }}
6361

6462
deploy:
6563
needs: [prepare-variables, build-push]
66-
runs-on: ubuntu-22.04
64+
runs-on: ubuntu-24.04
6765
permissions: {}
66+
6867
steps:
6968
- name: Get Token
7069
id: get-token
@@ -76,15 +75,14 @@ jobs:
7675
- name: Trigger staging deployment
7776
env:
7877
GITHUB_TOKEN: ${{ steps.get-token.outputs.token }}
79-
UNIQUE_IMAGE_TAG: ${{ needs.prepare-variables.outputs.unique_image_tag }}
78+
IMAGE_TAG: ${{ needs.prepare-variables.outputs.image_tag }}
8079
run: |
8180
payload=$(
82-
jq --arg image_tag "$UNIQUE_IMAGE_TAG" -n '{
81+
jq -n --arg image_tag "$IMAGE_TAG" '{
8382
"event_type": "saleor-mcp-staging",
8483
"client_payload": {
8584
"image_tag": $image_tag
8685
}
8786
}'
8887
)
89-
9088
gh api /repos/saleor/saleor-cloud-deployments/dispatches --input - <<< "$payload"

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ jobs:
1414
name: "Run linters and tests"
1515

1616
steps:
17-
- uses: actions/checkout@v4
18-
17+
- uses: actions/checkout@v6
18+
1919
- name: Install uv
2020
uses: astral-sh/setup-uv@v4
2121
with:
2222
version: "latest"
23-
23+
2424
- name: Install dependencies
2525
run: uv sync --dev
26-
26+
2727
- name: Run linting
2828
run: uv run ruff check .
29-
29+
3030
- name: Run typechecker
3131
run: uv run ty check
32-
32+
3333
- name: Run tests
3434
run: uv run pytest

0 commit comments

Comments
 (0)