Skip to content

Commit 81a37e1

Browse files
Harden long-runner image workflow
1 parent 27e5658 commit 81a37e1

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

.github/workflows/long-runner-ci.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,39 @@ on:
1010
jobs:
1111
build-and-push:
1212
runs-on: ubuntu-latest
13+
env:
14+
AWS_ROLE_TO_ASSUME: ${{ secrets.AWS_ROLE_TO_ASSUME }}
15+
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
1316
permissions:
1417
contents: read
1518
id-token: write # For OIDC auth to cloud registry (e.g. AWS ECR)
1619

1720
steps:
1821
- uses: actions/checkout@v4
1922

23+
- name: Resolve image tags
24+
id: image
25+
run: |
26+
if [ "${GITHUB_REF}" = "refs/heads/main" ] && [ -n "${ECR_REPOSITORY}" ]; then
27+
echo "push=true" >> "$GITHUB_OUTPUT"
28+
echo "runner_tag=${ECR_REPOSITORY}:latest" >> "$GITHUB_OUTPUT"
29+
echo "worker_tag=${ECR_REPOSITORY}:worker" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "push=false" >> "$GITHUB_OUTPUT"
32+
echo "runner_tag=bitcode-long-runner:ci" >> "$GITHUB_OUTPUT"
33+
echo "worker_tag=bitcode-long-runner-worker:ci" >> "$GITHUB_OUTPUT"
34+
fi
35+
2036
# Optionally configure AWS credentials – replace with GCP/Azure/Fly
2137
- name: Configure AWS credentials
22-
if: env.AWS_ROLE_TO_ASSUME != ''
38+
if: steps.image.outputs.push == 'true' && env.AWS_ROLE_TO_ASSUME != ''
2339
uses: aws-actions/configure-aws-credentials@v4
2440
with:
2541
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
2642
aws-region: us-east-1
2743

2844
- name: Login to Amazon ECR
29-
if: env.AWS_ROLE_TO_ASSUME != ''
45+
if: steps.image.outputs.push == 'true' && env.AWS_ROLE_TO_ASSUME != ''
3046
id: login-ecr
3147
uses: aws-actions/amazon-ecr-login@v2
3248

@@ -41,13 +57,13 @@ jobs:
4157
with:
4258
context: .
4359
file: Dockerfile.long-runner
44-
push: ${{ github.ref == 'refs/heads/main' }}
45-
tags: ${{ secrets.ECR_REPOSITORY }}:latest
60+
push: ${{ steps.image.outputs.push == 'true' }}
61+
tags: ${{ steps.image.outputs.runner_tag }}
4662

4763
- name: Build and Push Worker
4864
uses: docker/build-push-action@v5
4965
with:
5066
context: .
5167
file: Dockerfile.long-runner-worker
52-
push: ${{ github.ref == 'refs/heads/main' }}
53-
tags: ${{ secrets.ECR_REPOSITORY }}:worker
68+
push: ${{ steps.image.outputs.push == 'true' }}
69+
tags: ${{ steps.image.outputs.worker_tag }}

0 commit comments

Comments
 (0)