-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build and Deploy OCI Image of hplip-printer-app Using Rockcraft (#21)
- Added rockcraft.yaml, parts taken from snap/snapcraft.yaml - Added scripts to start Avahi and D-Bus support in the container and to start the Printer Application itself, optionally on a user-selected port - Moved patches from snap/ subdirectory to separate patches/ subdirectory for use by both Snap and Rock - Added and updated the GitHub workflows, for updating and versioning automation of the Rock, CI testing, and registering OCI image in Docker and GitHub - Added documentation for the Rock/OCI image to README.md
- Loading branch information
1 parent
fac2368
commit f13b641
Showing
12 changed files
with
1,173 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: CI Pipeline for hplip-printer-app | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-rock: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Pack with Rockcraft | ||
uses: canonical/craft-actions/rockcraft-pack@main | ||
id: rockcraft | ||
|
||
build-snap: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build Snap Package | ||
uses: snapcore/action-build@v1 | ||
id: snapcraft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Pack and Publish OCI Image to Docker Registry and GitHub Packages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
workflow_dispatch: | ||
inputs: | ||
workflow_choice: | ||
description: "Choose Release Channel" | ||
required: true | ||
default: "edge" | ||
type: choice | ||
options: | ||
- edge | ||
- stable | ||
- both | ||
workflow_run: | ||
workflows: ["Push new tag update to stable branch"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
build-rock: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Pack with Rockcraft | ||
uses: canonical/craft-actions/rockcraft-pack@main | ||
id: rockcraft | ||
|
||
- name: Upload Rock Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cups-rock | ||
path: ${{ steps.rockcraft.outputs.rock }} | ||
|
||
publish-rock: | ||
needs: build-rock | ||
if: github.ref_name == 'main' || github.ref_name == 'master' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download Rock Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: cups-rock | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo snap install rockcraft --classic | ||
sudo snap install docker | ||
sudo snap install yq | ||
- name: Ensure Docker Daemon is Running | ||
run: | | ||
sudo systemctl start docker | ||
sudo systemctl enable docker | ||
sudo systemctl is-active --quiet docker || sudo systemctl start docker | ||
# - name: Log in to Docker Hub | ||
# uses: docker/[email protected] | ||
# with: | ||
# username: ${{ secrets.DOCKER_USERNAME }} | ||
# password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Log in to GitHub Packages | ||
uses: docker/[email protected] | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and Push Docker Image (Edge & Latest Channel) | ||
if: github.event.inputs.workflow_choice == 'edge' || github.event.inputs.workflow_choice == 'both' || github.event_name == 'push' || github.event_name == 'workflow_run' | ||
env: | ||
USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
run: | | ||
IMAGE="$(yq '.name' rockcraft.yaml)" | ||
VERSION="$(yq '.version' rockcraft.yaml)" | ||
ROCK="$(ls *.rock | tail -n 1)" | ||
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-edge" | ||
# Push to Docker Hub | ||
# docker push ${USERNAME}/${IMAGE}:${VERSION}-edge | ||
# docker tag ${USERNAME}/${IMAGE}:${VERSION}-edge ${USERNAME}/${IMAGE}:latest | ||
# docker push ${USERNAME}/${IMAGE}:latest | ||
# Push to GitHub Packages | ||
GITHUB_IMAGE="ghcr.io/${{ github.repository_owner }}/${IMAGE}" | ||
docker tag ${USERNAME}/${IMAGE}:${VERSION}-edge ${GITHUB_IMAGE}:${VERSION}-edge | ||
docker push ${GITHUB_IMAGE}:${VERSION}-edge | ||
docker tag ${GITHUB_IMAGE}:${VERSION}-edge ${GITHUB_IMAGE}:latest | ||
docker push ${GITHUB_IMAGE}:latest | ||
- name: Build and Push Docker Image (Stable Channel) | ||
if: github.event.inputs.workflow_choice == 'stable' || github.event.inputs.workflow_choice == 'both' | ||
env: | ||
USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
run: | | ||
IMAGE="$(yq '.name' rockcraft.yaml)" | ||
VERSION="$(yq '.version' rockcraft.yaml)" | ||
ROCK="$(ls *.rock | tail -n 1)" | ||
sudo rockcraft.skopeo --insecure-policy copy oci-archive:"${ROCK}" docker-daemon:"${USERNAME}/${IMAGE}:${VERSION}-stable" | ||
# Push to Docker Hub | ||
# docker push ${USERNAME}/${IMAGE}:${VERSION}-stable | ||
# Push to GitHub Packages | ||
GITHUB_IMAGE="ghcr.io/${{ github.repository_owner }}/${IMAGE}" | ||
docker tag ${USERNAME}/${IMAGE}:${VERSION}-stable ${GITHUB_IMAGE}:${VERSION}-stable | ||
docker push ${GITHUB_IMAGE}:${VERSION}-stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.snap | ||
*.rock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.