Skip to content

Commit

Permalink
Move charmed-kafka from DockerHub to GitHub Container Registry (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
taurus-forever authored Mar 27, 2023
1 parent f9a172d commit 078f48c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 15 additions & 14 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,19 +31,18 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: charmed-kafka

- name: Login to Docker Hub
uses: docker/#-action@v1
- name: Login to GitHub Container Registry
uses: docker/#-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}

0 comments on commit 078f48c

Please # to comment.