From 078f48c33010516e25a6210557673dd03bde5556 Mon Sep 17 00:00:00 2001 From: Alex Lutay <1928266+taurus-forever@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:13:08 +0200 Subject: [PATCH] Move charmed-kafka from DockerHub to GitHub Container Registry (#6) --- .github/workflows/build.yaml | 14 ++++++++++---- .github/workflows/publish.yaml | 29 +++++++++++++++-------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 58ab553..3dfce6e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,12 +30,18 @@ jobs: uses: actions/checkout@v3 - name: Setup LXD uses: canonical/setup-lxd@main - - name: Install rockcraft + - name: Install dependencies run: | - sudo snap install --classic --channel edge rockcraft + sudo snap install yq + sudo snap install rockcraft --classic --edge - name: Build ROCK - run: rockcraft pack --verbose - + run: | + app_version=$(yq '.version' rockcraft.yaml) + version=$(yq '(.version|split("-"))[0]' rockcraft.yaml) + base=$(yq '(.base|split(":"))[1]' rockcraft.yaml) + tag=${version}-${base}_edge + sed -i "s/${app_version}/${tag}/g" rockcraft.yaml + rockcraft pack --verbose - name: Upload locally built ROCK artifact uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index c4f0667..2c0e815 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -11,6 +11,8 @@ jobs: needs: build runs-on: ubuntu-latest timeout-minutes: 5 + permissions: + packages: write steps: - name: Checkout repository uses: actions/checkout@v3 @@ -29,19 +31,18 @@ jobs: - uses: actions/download-artifact@v3 with: name: charmed-kafka - - - name: Login to Docker Hub - uses: docker/login-action@v1 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Import and push to Docker Hub + registry: ghcr.io + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + - name: Import and push to GHCR run: | - version="$(cat rockcraft.yaml | yq e '.version')" - sudo skopeo \ - --insecure-policy \ - copy \ - oci-archive:"charmed-kafka_${version}_amd64.rock" \ - docker-daemon:"charmed/kafka:${version}" - docker push "charmed/kafka:${version}" + version=$(yq '(.version|split("-"))[0]' rockcraft.yaml) + base=$(yq '(.base|split(":"))[1]' rockcraft.yaml) + tag=${version}-${base}_edge + sudo skopeo --insecure-policy copy \ + oci-archive:charmed-kafka_${tag}_amd64.rock \ + docker-daemon:ghcr.io/canonical/charmed-kafka:${tag} + docker push ghcr.io/canonical/charmed-kafka:${tag}