Skip to content

Commit 231cde1

Browse files
authored
Update build-runner workflow to be compatible with forks, fix image push (#117)
Partly revert and enhances #115 This is a follow-up to #115 that replaces the hardcoded `summerwind` portion of the image name with `${{ github.repository_owner }}` to enable contributors to test the image pushing behavior and fixes image building by conditionally passing `--push` to the build step based on the event that triggered the workflow. After setting the `DOCKER_ACCESS_TOKEN` Secret on my fork of this repository, I was able to use this updated workflow to [build and push](https://github.com/urcomputeringpal/actions-runner-controller/runs/1242793758?check_suite_focus=true) a [set of images](https://hub.docker.com/r/urcomputeringpal/actions-runner/tags) and confirm their functionality. I imagine this will be useful to future contributors who wish to help with the chore of keeping up with https://github.com/actions/runner/releases.
1 parent c986c55 commit 231cde1

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

.github/workflows/build-runner.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
env:
2222
RUNNER_VERSION: 2.273.5
2323
DOCKER_VERSION: 19.03.12
24+
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
2425
steps:
2526
- name: Checkout
2627
uses: actions/checkout@v2
@@ -33,19 +34,31 @@ jobs:
3334

3435
- name: Build Container Image
3536
working-directory: runner
37+
if: ${{ github.event_name == 'pull_request' }}
3638
run: |
3739
docker buildx build \
3840
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
3941
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
4042
--platform linux/amd64,linux/arm64 \
41-
--tag summerwind/actions-runner:v${RUNNER_VERSION} \
43+
--tag ${DOCKERHUB_USERNAME}/actions-runner:v${RUNNER_VERSION} \
44+
--tag ${DOCKERHUB_USERNAME}/actions-runner:latest \
4245
-f Dockerfile .
4346
44-
- name: Push Container Image
47+
- name: Login to GitHub Docker Registry
48+
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
49+
if: ${{ github.event_name == 'push' }}
50+
env:
51+
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
52+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }}
53+
54+
- name: Build and Push Container Image
4555
working-directory: runner
46-
run: |
47-
docker login -u summerwind --password-stdin <<<${{ secrets.DOCKER_ACCESS_TOKEN }}
48-
docker push summerwind/actions-runner:v${RUNNER_VERSION}
49-
docker tag summerwind/actions-runner:v${RUNNER_VERSION} summerwind/actions-runner:latest
50-
docker push summerwind/actions-runner:latest
5156
if: ${{ github.event_name == 'push' }}
57+
run: |
58+
docker buildx build \
59+
--build-arg RUNNER_VERSION=${RUNNER_VERSION} \
60+
--build-arg DOCKER_VERSION=${DOCKER_VERSION} \
61+
--platform linux/amd64,linux/arm64 \
62+
--tag ${DOCKERHUB_USERNAME}/actions-runner:v${RUNNER_VERSION} \
63+
--tag ${DOCKERHUB_USERNAME}/actions-runner:latest \
64+
-f Dockerfile . --push

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ jobs:
3838
- name: Login to GitHub Docker Registry
3939
run: echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
4040
env:
41-
DOCKERHUB_USERNAME: summerwind
41+
DOCKERHUB_USERNAME: ${{ github.repository_owner }}
4242
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_ACCESS_TOKEN }}
4343

4444
- name: Build Container Image
4545
run: |
4646
docker buildx build \
4747
--platform linux/amd64,linux/arm64 \
48-
--tag summerwind/actions-runner-controller:${{ env.VERSION }} \
48+
--tag ${DOCKERHUB_USERNAME}/actions-runner-controller:${{ env.VERSION }} \
4949
-f Dockerfile . --push

0 commit comments

Comments
 (0)