Skip to content

Commit

Permalink
add ci workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
reneradoi committed Jun 17, 2024
1 parent ac63a1d commit e2405d7
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build ROCK

on:
workflow_call:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Install dependencies
run: |
sudo snap install yq
sudo snap install rockcraft --classic
- name: Build ROCK
run: |
rockcraft pack
- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v3
with:
name: valkey-rock
path: charmed-valkey_*_amd64.rock
55 changes: 55 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish to GHCR

env:
RELEASE: edge

on:
push:
branches:
- main

jobs:
build:
uses: ./.github/workflows/build.yaml
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker
run: |
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
- name: Install skopeo
run: |
sudo snap install --devmode --channel edge skopeo
- name: Install yq
run: |
sudo snap install yq
- uses: actions/download-artifact@v3
with:
name: valkey-rock
path: .
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Import and push to GHCR
run: |
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
rock_image_version=$(yq '(.version)' rockcraft.yaml)
base=$(yq '(.base|split("@"))[1]' rockcraft.yaml)
tag=${version}-${base}-${{ env.RELEASE }}
echo "Publishing charmed-valkey:${tag}"
sudo skopeo --insecure-policy copy \
oci-archive:charmed-valkey_${rock_image_version}_amd64.rock \
docker-daemon:ghcr.io/canonical/charmed-valkey:${tag}
docker push ghcr.io/canonical/charmed-valkey:${tag}
2 changes: 1 addition & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ platforms: # The platforms this ROCK should be built on and run on
amd64:

services:
redis:
valkey:
override: replace
startup: enabled
summary: Start Valkey
Expand Down

0 comments on commit e2405d7

Please sign in to comment.