Skip to content

Commit

Permalink
Switch to GHCR
Browse files Browse the repository at this point in the history
Switches the project to push images to ghcr instead of docker hub. This
integrates better with GitHub actions
  • Loading branch information
JoshuaWatt committed Dec 4, 2024
1 parent 18762cc commit 22a0011
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
- {image: ubuntu-24.04-oegarmin, provider: docker, sh: bash}

runs-on: ubuntu-20.04
permissions:
packages: write
contents: read

env:
USE_HELPER: "1"
Expand All @@ -101,7 +104,6 @@ jobs:
- name: Install packages
run: |
sudo mkdir -p /etc/containers/
echo -e "[registries.search]\nregistries = ['docker.io']\n" | sudo tee /etc/containers/registries.conf
echo '{ "features": { "buildkit": true } }' | sudo tee /etc/docker/daemon.json
sudo apt -y install \
diffstat \
Expand Down Expand Up @@ -135,11 +137,9 @@ jobs:
run: |
coverage3 combine
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
if: ${{ ( github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master' ) && github.event_name == 'push' && matrix.provider == 'docker' }}

- name: Push image
Expand All @@ -148,6 +148,6 @@ jobs:
if [ "$TAG" = "master" ]; then
TAG="latest"
fi
docker tag garminpyrex/${{ matrix.image }}:ci-test garminpyrex/${{ matrix.image }}:$TAG
docker push garminpyrex/${{ matrix.image }}:$TAG
docker tag ghcr.io/garmin/${{ matrix.image }}:ci-test garminpyrex/${{ matrix.image }}:$TAG
docker push ghcr.io/garmin/${{ matrix.image }}:$TAG
if: ${{ ( github.ref == 'refs/heads/next' || github.ref == 'refs/heads/master' ) && github.event_name == 'push' && matrix.provider == 'docker' }}
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ jobs:
python3 -m pip install --upgrade pip
pip3 install requests
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Deploy image
run: |
Expand Down
2 changes: 1 addition & 1 deletion ci/build_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def main():
provider,
"build",
"-t",
"garminpyrex/%s:ci-test" % args.image,
"ghcr.io/garmin/%s:ci-test" % args.image,
"-f",
docker_file,
"--network=host",
Expand Down
9 changes: 4 additions & 5 deletions ci/deploy_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ def deploy_image(top_dir, image, tag):

(_, _, image_type) = image.split("-")

repo = "garminpyrex/%s" % image
name = "%s:%s" % (repo, tag)
repo = "garmin/%s" % image
name = "ghcr.io/%s:%s" % (repo, tag)

print("Deploying %s..." % name)

# Get a login token for the Docker registry and download the manifest
token = requests.get(
"https://auth.docker.io/token?service=registry.docker.io&scope=repository:%s:pull"
% repo,
"https://ghcr.io/token?scope=repository:%s:pull" % repo,
json=True,
).json()["token"]
manifest = requests.get(
"https://registry.hub.docker.com/v2/%s/manifests/%s" % (repo, tag),
"https://ghcr.io/v2/%s/manifests/%s" % (repo, tag),
headers={"Authorization": "Bearer %s" % token},
json=True,
).json()
Expand Down
4 changes: 2 additions & 2 deletions pyrex.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ confversion = @CONFVERSION@

# The name of the tag given to the image. If you want to keep around different
# Pyrex images simultaneously, each should have a unique tag
%tag = garminpyrex/${config:image}:${config:pyrextag}
%tag = garmin/${config:image}:${config:pyrextag}

# If set to 1, the image is built up locally every time the environment is
# sourced. If set to 0, building the image will be skipped, which means that
Expand All @@ -49,7 +49,7 @@ confversion = @CONFVERSION@

# The name of the registry where to find the image whose complete name is stored
# in tag variable. This variable is only used when buildlocal is set to 0.
%registry = docker.io
%registry = ghcr.io

# A list of environment variables that should be imported as Pyrex
# configuration variables in the "env" section, e.g. ${env:HOME}. Note that
Expand Down

0 comments on commit 22a0011

Please sign in to comment.