Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to GHCR #99

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 1 addition & 5 deletions pyrex.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,14 @@ 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 = ghcr.io/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
# the container engine may attempt to download a prebuilt image from a
# repository
%buildlocal = 0

# 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

# A list of environment variables that should be imported as Pyrex
# configuration variables in the "env" section, e.g. ${env:HOME}. Note that
# environment variables accessed in this way must be set or an error will
Expand Down
6 changes: 0 additions & 6 deletions pyrex.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,6 @@ def build_image(config, build_config):

build_config["build"]["buildhash"] = get_build_hash(build_config)
else:
registry = config["config"].get("registry")
if registry:
if not registry.endswith("/"):
registry = registry + "/"
tag = registry + tag

try:
# Try to get the image This will fail if the image doesn't
# exist locally
Expand Down
Loading