Skip to content

Commit 6c4bfd2

Browse files
committed
ci: github actions security
1 parent fb2bca9 commit 6c4bfd2

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

.github/workflows/publish.yml

+20-17
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,28 @@ jobs:
2828
steps:
2929
- uses: actions/checkout@v2
3030

31-
# Setup docker to build for multiple platforms (requires qemu).
32-
# See:
33-
# https://github.com/docker/build-push-action/tree/v2.3.0#usage
34-
# https://github.com/docker/build-push-action/blob/v2.3.0/docs/advanced/multi-platform.md
31+
# Setup docker to build for multiple platforms, see:
32+
# https://github.com/docker/build-push-action/tree/HEAD#usage
3533

36-
- name: Set up QEMU
37-
uses: docker/setup-qemu-action@v1
34+
- name: Set up QEMU (for docker buildx)
35+
uses: docker/setup-qemu-action@25f0500ff22e406f7191a2a8ba8cda16901ca018 # associated tag: v1.0.2
3836

39-
- name: Set up Docker Buildx
40-
uses: docker/setup-buildx-action@v1
37+
- name: Set up Docker Buildx (for multi-arch builds)
38+
uses: docker/setup-buildx-action@2a4b53665e15ce7d7049afb11ff1f70ff1610609 # associated tag: v1.1.2
4139

42-
# https://github.com/docker/login-action/tree/v1.8.0#docker-hub
43-
- name: Login to Docker Hub
44-
uses: docker/login-action@v1
40+
- name: Setup push rights to Docker Hub
41+
# This was setup by...
42+
# 1. Creating a Docker Hub service account "jupyterhubbot"
43+
# 2. Creating a access token for the service account specific to this
44+
# repository: https://hub.docker.com/settings/security
45+
# 3. Making the account part of the "bots" team, and granting that team
46+
# permissions to push to the relevant images:
47+
# https://hub.docker.com/orgs/jupyterhub/teams/bots/permissions
48+
# 4. Registering the username and token as a secret for this repo:
49+
# https://github.com/jupyterhub/configurable-http-proxy/settings/secrets/actions
4550
if: startsWith(github.ref, 'refs/tags/')
46-
with:
47-
username: ${{ secrets.DOCKERHUB_USERNAME }}
48-
password: ${{ secrets.DOCKERHUB_TOKEN }}
51+
run: |
52+
docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}"
4953
5054
# https://github.com/jupyterhub/action-major-minor-tag-calculator
5155
# If this is a tagged build this will return additional parent tags.
@@ -56,8 +60,7 @@ jobs:
5660
# If GITHUB_TOKEN isn't available (e.g. in PRs) returns no tags [].
5761
- name: Get list of tags
5862
id: gettags
59-
# TODO: Move to org?
60-
uses: jupyterhub/action-major-minor-tag-calculator@main
63+
uses: jupyterhub/action-major-minor-tag-calculator@v1
6164
with:
6265
githubToken: ${{ secrets.GITHUB_TOKEN }}
6366
prefix: "jupyterhub/configurable-http-proxy:"
@@ -66,7 +69,7 @@ jobs:
6669
run: echo "Docker tags ${{ steps.gettags.outputs.tags }}"
6770

6871
- name: Build and push
69-
uses: docker/build-push-action@v2
72+
uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f # associated tag: v2.4.0
7073
with:
7174
platforms: linux/amd64,linux/arm64
7275
push: ${{ startsWith(github.ref, 'refs/tags/') }}

0 commit comments

Comments
 (0)