Skip to content

Commit

Permalink
chore: add GitHub container registry for stable images (#521)
Browse files Browse the repository at this point in the history
* chore: extend docs

* chore(wip): attach ghcr

* chore(test): mock a docker-build-push run

* chore(test): verify `unstable` skips GHCR

* chore(test): second mock attempt to skip GHCR

* chore: cleanup after successful tests
  • Loading branch information
dee-me-tree-or-love committed Aug 30, 2023
1 parent 4645f7b commit 6417769
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,20 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}
print-hash: true

## DOCKER
## DOCKER (DOCKER HUB & CONTAINER REGISTRY)

# figure out which docker tags we need to push
docker-determine-tags:
runs-on: "ubuntu-latest"
needs:
- "tests"
env:
STABLE_IMAGES: '["pypiserver/pypiserver", "ghcr.io/pypiserver/pypiserver"]'
FLEXIBLE_IMAGES: '["pypiserver/pypiserver"]'
outputs:
tags: "${{ steps.tags.outputs.tags }}"
has_tags: "${{ steps.has_tags.outputs.has_tags }}"
images: ${{ contains(steps.tags.outputs.tags, 'unstable') && env.FLEXIBLE_IMAGES || env.STABLE_IMAGES }}
steps:
- uses: "actions/checkout@v3"

Expand All @@ -166,10 +173,6 @@ jobs:
run: >-
echo "::set-output name=has_tags::$(bin/ci_helper.py ${{ github.ref }} has_tags)"
outputs:
tags: "${{ steps.tags.outputs.tags }}"
has_tags: "${{ steps.has_tags.outputs.has_tags }}"

# Deploy any needed docker tags
deploy-docker:
runs-on: "ubuntu-latest"
Expand All @@ -179,6 +182,7 @@ jobs:
strategy:
matrix:
tag: "${{ fromJson(needs.docker-determine-tags.outputs.tags) }}"
image: "${{ fromJson(needs.docker-determine-tags.outputs.images) }}"
steps:
- uses: "actions/checkout@v3"

Expand All @@ -196,6 +200,13 @@ jobs:
username: "${{ secrets.DOCKER_HUB_USER }}"
password: "${{ secrets.DOCKER_HUB_TOKEN }}"

- name: "Login to GitHub Container Registry"
uses: "docker/login-action@v2"
with:
registry: "ghcr.io"
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: "Set up Docker Buildx"
id: "buildx"
uses: "docker/setup-buildx-action@v1"
Expand All @@ -208,7 +219,7 @@ jobs:
file: "./Dockerfile"
builder: "${{ steps.buildx.outputs.name }}"
push: true
tags: "pypiserver/pypiserver:${{ matrix.tag }}"
tags: "${{ matrix.image }}:${{ matrix.tag }}"
cache-from: "type=local,src=/tmp/.buildx-cache"
cache-to: "type=local,dest=/tmp/.buildx-cache"

Expand Down
12 changes: 11 additions & 1 deletion docs/contents/repo-maintenance/release-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ flowchart LR
pk["build-and-pack 📦"]
py["pypi-index 🗃️"]
do["docker-hub 🐳"]
gh["gh-container-registry 🚀"]
gr["github-release 📣"]
subgraph "Preparation 🌱"
Expand All @@ -23,7 +24,7 @@ flowchart LR
rm-->ci-->pk
end
subgraph "Deploy 🌳"
pk--> py & do & gr
pk--> py & do & gh & gr
end
```

Expand Down Expand Up @@ -101,6 +102,15 @@ If all is successful so far, [`ci.yml`](../../../.github/workflows/ci.yml) tags
the built docker images and pushes them to the
[`pypiserver` Docker Hub repository](https://hub.docker.com/r/pypiserver/pypiserver).

#### Publish to GitHub Container Registry 🚀

> 🏷️ Docker image *tags* are determined on the fly.
For all `stable` (i.e. `latest`, tag, release ...) tags derived by
[`ci.yml`](../../../.github/workflows/ci.yml) tags,
the built docker images are *also* pushed to
[`pypiserver` GitHub Container Registry](https://github.com/orgs/pypiserver/packages?repo_name=pypiserver).

#### Publish a GitHub Release draft 📣

> 🛠️ *This step is applicable only for maintainers.*
Expand Down

0 comments on commit 6417769

Please sign in to comment.