Skip to content

Commit

Permalink
Upload image to ghcr.io too (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
natsukagami authored Dec 14, 2020
1 parent aec0221 commit 5c24461
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 22 deletions.
58 changes: 46 additions & 12 deletions .github/workflows/docker-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,62 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v1
- name: Prepare version tags
run: echo ${{ github.ref }} | xargs basename | echo ::set-env name=VERS::$(awk -F "." '{ print $1 "," $1 "." $2 "," $1 "." $2 "." $3 }')
- name: Publish
uses: docker/build-push-action@v1
run: |
echo "tags<<EOF" >> $GITHUB_ENV
scripts/format_docker_tags.py $(basename ${{ github.ref }}) >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: natsukagami/kjudge
tags: ${{ env.VERS }},latest
dockerfile: ./docker/Dockerfile
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Publish
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.tags }}
file: ./docker/Dockerfile
latest-gcc:
name: GCC-only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Prepare version tags
run: echo ${{ github.ref }} | xargs basename | echo ::set-env name=VERS_GCC::$(awk -F "." '{ print $1 "," $1 "." $2 "," $1 "." $2 "." $3 }' | sed -E 's/(,|$)/-gcc\1/g')
- name: Publish
uses: docker/build-push-action@v1
run: |
echo "tags<<EOF" >> $GITHUB_ENV
scripts/format_docker_tags.py $(basename ${{ github.ref }}) "-gcc" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: natsukagami/kjudge
tags: ${{ env.VERS_GCC }},latest-gcc
dockerfile: ./docker/gcc-only.dockerfile
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Publish
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.tags }}
file: ./docker/gcc-only.dockerfile
58 changes: 48 additions & 10 deletions .github/workflows/docker-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,63 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Publish
uses: docker/build-push-action@v1
- name: Prepare version tags
run: |
echo "tags<<EOF" >> $GITHUB_ENV
scripts/format_docker_tags.py "unstable" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: natsukagami/kjudge
tags: unstable
dockerfile: ./docker/Dockerfile
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Publish
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.tags }}
file: ./docker/gcc-only.dockerfile
unstable-gcc:
name: GCC-only
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Publish
uses: docker/build-push-action@v1
- name: Prepare version tags
run: |
echo "tags<<EOF" >> $GITHUB_ENV
scripts/format_docker_tags.py "unstable" "-gcc" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: natsukagami/kjudge
tags: unstable-gcc
dockerfile: ./docker/gcc-only.dockerfile
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Publish
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ env.tags }}
file: ./docker/gcc-only.dockerfile
23 changes: 23 additions & 0 deletions scripts/format_docker_tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
#
# Outputs a list of Docker tags appropriate for the docker file.
# ./format_docker_tags.py <"unstable" | a SemVer version string> [suffix]
import sys

version = sys.argv[1]
version_numbers = version.split(".")
version_tags = [ ".".join(version_numbers[:i+1]) for i in range(0, len(version_numbers)) ]

# Latest is also a version_tag
if version != "unstable":
version_tags.append("latest")

suffix = ""
if len(sys.argv) == 3:
suffix = sys.argv[2]

base = ["natsukagami/kjudge", "ghcr.io/natsukagami/kjudge"]

for b in base:
for v in version_tags:
print(b + ":" + v + suffix)

0 comments on commit 5c24461

Please sign in to comment.