Skip to content

Commit d96b572

Browse files
committed
chore(docker): modernize registry and improve workflow
- Migrate from docker.pkg.github.com to ghcr.io (GitHub Container Registry) - Update branch reference from master to main in README - Add proper Docker usage section in README - Improve metadata extraction in Docker publish workflow - Add GitHub Container Registry link for users - Simplify Docker image tagging strategy This modernization aligns with GitHub's current best practices and provides better container registry experience.
1 parent d6cca13 commit d96b572

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

.github/workflows/docker-publish.yml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Docker
22

33
on:
44
push:
5-
# Publish `master` as Docker `latest` image.
5+
# Publish `main` as Docker `latest` image.
66
branches:
7-
- master
7+
- main
88

99
# Publish `v1.2.3` tags as releases.
1010
tags:
@@ -14,8 +14,7 @@ on:
1414
pull_request:
1515

1616
env:
17-
# TODO: Change variable to your image's name.
18-
IMAGE_NAME: image
17+
IMAGE_NAME: codestats-readme
1918

2019
jobs:
2120
# Run tests.
@@ -24,7 +23,7 @@ jobs:
2423
runs-on: ubuntu-latest
2524

2625
steps:
27-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
2827

2928
- name: Setup pnpm
3029
uses: pnpm/action-setup@v4
@@ -66,32 +65,38 @@ jobs:
6665
if: github.event_name == 'push'
6766

6867
steps:
69-
- uses: actions/checkout@v2
68+
- uses: actions/checkout@v4
7069

7170
- name: Build image
7271
run: docker build . --file Dockerfile --tag $IMAGE_NAME
7372

74-
- name: Log into registry
75-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
73+
- name: Log into GitHub Container Registry
74+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
7675

77-
- name: Push image
76+
- name: Extract metadata
77+
id: meta
7878
run: |
79-
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
80-
79+
# Generate image name
80+
IMAGE_ID=ghcr.io/${{ github.repository }}
81+
8182
# Change all uppercase to lowercase
8283
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
83-
84+
8485
# Strip git ref prefix from version
8586
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
86-
87+
8788
# Strip "v" prefix from tag name
8889
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
89-
90-
# Use Docker `latest` tag convention
91-
[ "$VERSION" == "master" ] && VERSION=latest
92-
93-
echo IMAGE_ID=$IMAGE_ID
94-
echo VERSION=$VERSION
95-
96-
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
97-
docker push $IMAGE_ID:$VERSION
90+
91+
# Use Docker `latest` tag convention for main branch
92+
[ "$VERSION" == "main" ] && VERSION=latest
93+
94+
echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_OUTPUT
95+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
96+
echo "FULL_TAG=$IMAGE_ID:$VERSION" >> $GITHUB_OUTPUT
97+
98+
- name: Push image to GitHub Container Registry
99+
run: |
100+
docker tag $IMAGE_NAME ${{ steps.meta.outputs.FULL_TAG }}
101+
docker push ${{ steps.meta.outputs.FULL_TAG }}
102+
echo "📦 Docker image pushed: ${{ steps.meta.outputs.FULL_TAG }}"

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Please follow the steps below:
4242
name: Update this repo's README
4343
runs-on: ubuntu-latest
4444
steps:
45-
- uses: vergissberlin/codestats-readme@master
45+
- uses: vergissberlin/codestats-readme@main
4646
with:
4747
CODESTATS_USERNAME: <username>
4848
```
@@ -61,9 +61,23 @@ Please follow the steps below:
6161

6262
I am a fan of minimal designs and the profile readme is a great way to show off your skills and interests. The CodeStats API, gets us a **lot of data** about a person's **coding activity**. Using up more data via the CodeStats API will clutter the profile readme and hinder your chances on displaying what you provide **value to the community** like the pinned Repositories. You are _**exercising these languages or learning a new language**_, this will also show that you spend some amount of time to learn and exercise your development skills. That's what matters in the end :heart:
6363

64+
## Usage as Docker Image
65+
66+
The action is also available as a Docker image, which can be used in any CI/CD system:
67+
68+
```bash
69+
# Using GitHub Container Registry (recommended)
70+
docker run --rm -v "$PWD:/workspace" -w /workspace \
71+
-e CODESTATS_USERNAME=your_username \
72+
-e GITHUB_TOKEN=your_token \
73+
ghcr.io/vergissberlin/codestats-readme:latest
74+
```
75+
76+
> **Note**: The Docker image is automatically built and pushed to [GitHub Container Registry](https://github.com/vergissberlin/codestats-readme/pkgs/container/codestats-readme) on every release.
77+
6478
## Testing
6579

66-
### Docker
80+
### Docker (Local Development)
6781

6882
```bash
6983
docker build -t vergissberlin/codestats-readme .

0 commit comments

Comments
 (0)