Skip to content

Commit 1057d0c

Browse files
authored
Tag workflow dispatch with PR (#42)
1 parent 4b6a826 commit 1057d0c

File tree

9 files changed

+29
-34
lines changed

9 files changed

+29
-34
lines changed

.github/actions/build/action.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ outputs:
1919
version:
2020
description: "The version for the image"
2121
value: ${{ steps.meta.outputs.version }}
22+
image:
23+
description: "The Docker image"
24+
value: ${{ steps.image.outputs.image }}
25+
image_version:
26+
description: "Combines image and version to a valid image tag"
27+
value: ${{ steps.image.outputs.image }}:${{ steps.meta.outputs.version }}
2228

2329
runs:
2430
using: "composite"
@@ -42,39 +48,22 @@ runs:
4248
username: ${{ inputs.username }}
4349
password: ${{ inputs.password }}
4450

45-
- name: Docker Tag
46-
id: tag
51+
- name: Docker Image
52+
id: image
4753
shell: bash
4854
run: |
49-
function export_tag() {
50-
echo "tag=$1" >> $GITHUB_OUTPUT
51-
exit 0
52-
}
53-
54-
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
55-
export_tag "type=ref,event=pr"
56-
elif [[ ${{ github.event_name }} == 'merge_group' ]]; then
57-
export_tag "type=raw,value=staging"
58-
elif [[ ${{ github.event_name }} == 'push' ]]; then
59-
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
60-
export_tag "type=raw,value=latest"
61-
else
62-
export_tag "type=sha"
63-
fi
64-
fi
65-
66-
echo "No tag found, exiting."
67-
echo "event_name: ${{ github.event_name }}"
68-
echo "ref: ${{ github.ref }}"
69-
70-
exit 1
55+
echo "image=ghcr.io/mozilla/test-github-features" >> $GITHUB_OUTPUT
7156
7257
- name: Docker meta
7358
id: meta
7459
uses: docker/metadata-action@v5
7560
with:
76-
images: ghcr.io/mozilla/test-github-features
77-
tags: ${{ steps.tag.outputs.tag }}
61+
images: ${{ steps.image.outputs.image }}
62+
tags: |
63+
type=raw,value=latest,enable={{is_default_branch}}
64+
type=raw,value=staging,enable=${{ github.event_name == 'merge_group' }}
65+
type=ref,event=pr
66+
type=sha
7867
7968
- name: Build Image
8069
uses: docker/build-push-action@v5

.github/workflows/deploy.development.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: ./.github/actions/deploy
2929
with:
3030
environment: development
31-
image: ${{ steps.build.outputs.tags }}
31+
image: ${{ steps.build.outputs.image_version }}
3232
version: ${{ steps.build.outputs.version }}
3333
fly_token: ${{ secrets.FLY_TOKEN }}
3434
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/deploy.production.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: ./.github/actions/deploy
2929
with:
3030
environment: production
31-
image: ${{ steps.build.outputs.tags }}
31+
image: ${{ steps.build.outputs.image_version }}
3232
version: ${{ steps.build.outputs.version }}
3333
fly_token: ${{ secrets.FLY_TOKEN }}
3434
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/deploy.staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: ./.github/actions/deploy
2727
with:
2828
environment: staging
29-
image: ${{ steps.build.outputs.tags }}
29+
image: ${{ steps.build.outputs.image_version }}
3030
version: ${{ steps.build.outputs.version }}
3131
fly_token: ${{ secrets.FLY_TOKEN }}
3232
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Test
1414
uses: ./.github/actions/run
1515
with:
16-
image: ${{ steps.build.outputs.tags }}
16+
image: ${{ steps.build.outputs.image_version }}
1717
run: |
1818
echo "Testing"
1919
npm ci
@@ -28,7 +28,7 @@ jobs:
2828
- name: Lint
2929
uses: ./.github/actions/run
3030
with:
31-
image: ${{ steps.build.outputs.tags }}
31+
image: ${{ steps.build.outputs.image_version }}
3232
run: |
3333
echo "Linting"
3434
npm ci

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,3 @@ RUN npm i --omit=dev --no-save
2424

2525
EXPOSE 3000
2626

27-
28-
CMD ["npm", "run", "start"]
29-

fly-development.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ primary_region = 'ams'
2121
memory = '1gb'
2222
cpu_kind = 'shared'
2323
cpus = 1
24+
25+
[experimental]
26+
cmd = ["npm", "run", "start"]

fly-production.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ primary_region = 'ams'
2121
memory = '1gb'
2222
cpu_kind = 'shared'
2323
cpus = 1
24+
25+
[experimental]
26+
cmd = ["npm", "run", "start"]

fly-staging.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ primary_region = 'ams'
2121
memory = '1gb'
2222
cpu_kind = 'shared'
2323
cpus = 1
24+
25+
[experimental]
26+
cmd = ["npm", "run", "start"]

0 commit comments

Comments
 (0)