Skip to content

Commit 98bf124

Browse files
committed
feat: modify action to build and consume container
To speed things up further, we can build and release the actual container on release publication, and then have the action itself consume the image instead of the Dockerfile. Additionally, we can force the release process to use the latest set of changes by defining a local GHA that uses the Dockerfile instead. I've proven this works at https://github.com/weierophinney/test-local-action/, where I observed that the build happens relative to the checkout directory, and not to where the action is defined. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
1 parent 259ad12 commit 98bf124

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Definition of the github action
2+
# as per https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
3+
4+
name: 'laminas/automatic-releases'
5+
description: 'Automates automatic releases for semver-compliant repositories'
6+
7+
inputs:
8+
command-name:
9+
description: |
10+
Command to execute: one of
11+
* `laminas:automatic-releases:release`
12+
* `laminas:automatic-releases:create-merge-up-pull-request`
13+
* `laminas:automatic-releases:switch-default-branch-to-next-minor`
14+
required: true
15+
16+
runs:
17+
using: 'docker'
18+
image: '../../../Dockerfile'
19+
args:
20+
- ${{ inputs.command-name }}

.github/workflows/automatic-release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: "actions/checkout@v2"
1818

1919
- name: "Release"
20-
uses: "./"
20+
uses: "./.github/actions/automatic-releases/"
2121
with:
2222
command-name: "laminas:automatic-releases:release"
2323
env:
@@ -27,7 +27,7 @@ jobs:
2727
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
2828

2929
- name: "Create Merge-Up Pull Request"
30-
uses: "./"
30+
uses: "./.github/actions/automatic-releases/"
3131
with:
3232
command-name: "laminas:automatic-releases:create-merge-up-pull-request"
3333
env:
@@ -37,7 +37,7 @@ jobs:
3737
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
3838

3939
- name: "Create and/or Switch to new Release Branch"
40-
uses: "./"
40+
uses: "./.github/actions/automatic-releases/"
4141
with:
4242
command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor"
4343
env:
@@ -47,7 +47,7 @@ jobs:
4747
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
4848

4949
- name: "Bump Changelog Version On Originating Release Branch"
50-
uses: "./"
50+
uses: "./.github/actions/automatic-releases/"
5151
with:
5252
command-name: "laminas:automatic-releases:bump-changelog"
5353
env:
@@ -57,7 +57,7 @@ jobs:
5757
"GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }}
5858

5959
- name: "Create new milestones"
60-
uses: "./"
60+
uses: "./.github/actions/automatic-releases/"
6161
with:
6262
command-name: "laminas:automatic-releases:create-milestones"
6363
env:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and push containers
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
tags:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
tags: ${{ steps.tags.outputs.tags }}
12+
steps:
13+
- name: Compile tag list
14+
id: tags
15+
run: |
16+
TAG=${GITHUB_REF/refs\/tags\//}
17+
PREFIX=ghcr.io/laminas/automatic-releases
18+
MAJOR="${PREFIX}:$(echo ${TAG} | cut -d. -f1)"
19+
MINOR="${MAJOR}.$(echo ${TAG} | cut -d. -f2)"
20+
PATCH="${PREFIX}:${TAG}"
21+
echo "::set-output name=tags::${MAJOR}%0A${MINOR}%0A${PATCH}"
22+
23+
release-container:
24+
runs-on: ubuntu-latest
25+
needs: [tags]
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
- name: Setup QEMU
30+
uses: docker/setup-qemu-action@v1
31+
- name: Setup Docker Buildx
32+
uses: docker/setup-buildx-action@v1
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v1
35+
with:
36+
registry: ghcr.io
37+
username: ${{ secrets.CONTAINER_USERNAME }}
38+
password: ${{ secrets.CONTAINER_PAT }}
39+
- name: Build and push
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: .
43+
file: ./Dockerfile
44+
platforms: linux/amd64
45+
push: true
46+
tags: ${{ needs.tags.outputs.tags }}
47+

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ inputs:
1515

1616
runs:
1717
using: 'docker'
18-
image: 'Dockerfile'
18+
image: 'docker://ghcr.io/laminas/automatic-releases:1'
1919
args:
2020
- ${{ inputs.command-name }}

0 commit comments

Comments
 (0)