From 85efc8c5c917573bfc009d61d6ffa6ac0c167f60 Mon Sep 17 00:00:00 2001 From: Luca Bello <36242061+lucabello@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:14:05 +0200 Subject: [PATCH] onboard to oci-factory (#10) --- .github/workflows/pull-request.yaml | 16 ++++++++++++ .github/workflows/rock-release-dev.yaml | 18 +++++++++++++ ...ock.yaml => rock-release-oci-factory.yaml} | 4 +-- .github/workflows/rock-update.yaml | 22 ++++++++++++++++ .github/workflows/test-rock.yaml | 25 ------------------ .github/workflows/update-rock.yaml | 14 ---------- rockcraft.yaml => 2.10.4/rockcraft.yaml | 0 README.md | 26 +++++++------------ 8 files changed, 68 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/pull-request.yaml create mode 100644 .github/workflows/rock-release-dev.yaml rename .github/workflows/{build-rock.yaml => rock-release-oci-factory.yaml} (53%) create mode 100644 .github/workflows/rock-update.yaml delete mode 100644 .github/workflows/test-rock.yaml delete mode 100644 .github/workflows/update-rock.yaml rename rockcraft.yaml => 2.10.4/rockcraft.yaml (100%) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000..4e0077b --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,16 @@ +name: Pull Requests + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + branches: + - main + +jobs: + pull-request: + name: PR + uses: canonical/observability/.github/workflows/rock-pull-request.yaml@main + secrets: inherit diff --git a/.github/workflows/rock-release-dev.yaml b/.github/workflows/rock-release-dev.yaml new file mode 100644 index 0000000..63f52a5 --- /dev/null +++ b/.github/workflows/rock-release-dev.yaml @@ -0,0 +1,18 @@ +name: "Publish ROCK to GHCR:dev" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + workflow_dispatch: {} + push: + branches: + - main + +jobs: + build: + uses: canonical/observability/.github/workflows/rock-release-dev.yaml@main + secrets: inherit + with: + rock-name: traefik diff --git a/.github/workflows/build-rock.yaml b/.github/workflows/rock-release-oci-factory.yaml similarity index 53% rename from .github/workflows/build-rock.yaml rename to .github/workflows/rock-release-oci-factory.yaml index f3b3ee3..f6372e2 100644 --- a/.github/workflows/build-rock.yaml +++ b/.github/workflows/rock-release-oci-factory.yaml @@ -1,4 +1,4 @@ -name: Build ROCK +name: Open a PR to OCI Factory on: workflow_dispatch: {} @@ -8,7 +8,7 @@ on: jobs: build: - uses: canonical/observability/.github/workflows/build-rock.yaml@main + uses: canonical/observability/.github/workflows/rock-release-oci-factory.yaml@main secrets: inherit with: rock-name: traefik diff --git a/.github/workflows/rock-update.yaml b/.github/workflows/rock-update.yaml new file mode 100644 index 0000000..0f89f7a --- /dev/null +++ b/.github/workflows/rock-update.yaml @@ -0,0 +1,22 @@ +name: Update ROCK + +on: + workflow_dispatch: {} + schedule: + - cron: '0 0,4,8,12,16,20 * * *' + +jobs: + build: + uses: canonical/observability/.github/workflows/rock-update.yaml@main + with: + rock-name: traefik + source-repo: traefik/traefik + check-go: true + update-script: | + # The caller must provide \$application_src and \$rockcraft_yaml + # \$application_src: The root folder of the cloned upstream project + # \$rockcraft_yaml: Path of the rockcraft.yaml to update + # + ## traefik-frontend dependency + source_tag=$(yq .parts.traefik.source-tag) + tag="\$source_tag" yq -i '.parts.traefik-frontend.source-tag = strenv(tag)' diff --git a/.github/workflows/test-rock.yaml b/.github/workflows/test-rock.yaml deleted file mode 100644 index f797795..0000000 --- a/.github/workflows/test-rock.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Pack ROCK - -on: - pull_request: {} - -jobs: - main: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup LXD - uses: canonical/setup-lxd@v0.1.1 - with: - channel: latest/stable - - - name: Install dependencies - run: | - sudo snap install --classic --channel edge rockcraft - - - name: Build ROCK - id: build_rock - run: | - rockcraft pack --verbose diff --git a/.github/workflows/update-rock.yaml b/.github/workflows/update-rock.yaml deleted file mode 100644 index d34d74d..0000000 --- a/.github/workflows/update-rock.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: Update ROCK - -on: - workflow_dispatch: {} - schedule: - - cron: '0 0,4,8,12,16,20 * * *' - -jobs: - build: - uses: canonical/observability/.github/workflows/update-rock.yaml@main - with: - rock-name: traefik - source-repo: traefik/traefik - check-go: true diff --git a/rockcraft.yaml b/2.10.4/rockcraft.yaml similarity index 100% rename from rockcraft.yaml rename to 2.10.4/rockcraft.yaml diff --git a/README.md b/README.md index 84a8a1a..5a611da 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,16 @@ # traefik-rock -[![Build ROCK](https://github.com/canonical/traefik-rock/actions/workflows/build-rock.yaml/badge.svg)](https://github.com/canonical/traefik-rock/actions/workflows/build-rock.yaml) +[![Open a PR to OCI Factory](https://github.com/canonical/traefik-rock/actions/workflows/rock-release-oci-factory.yaml/badge.svg)](https://github.com/canonical/traefik-rock/actions/workflows/rock-release-oci-factory.yaml) +[![Publish to GHCR:dev](https://github.com/canonical/traefik-rock/actions/workflows/rock-release-dev.yaml/badge.svg)](https://github.com/canonical/traefik-rock/actions/workflows/rock-release-dev.yaml) +[![Update ROCK](https://github.com/canonical/traefik-rock/actions/workflows/rock-update.yaml/badge.svg)](https://github.com/canonical/traefik-rock/actions/workflows/rock-update.yaml) -Automation for building a ROCK for Traefik. Every fourth hour, the automation checks whether -a new release has been cut in the upstream Traefik repo, and if so, creates a pull request with -the new version info. +[ROCKs](https://canonical-rockcraft.readthedocs-hosted.com/en/latest/) for [Traefik](https://traefik.io/). +This repository holds all the necessary files to build ROCKs for the upstream versions we support. The Traefik ROCK is used by the [traefik-k8s-operator](https://github.com/canonical/traefik-k8s-operator) charm. -Once the PR gets merged, a new ROCK is built and published on ghcr.io/canonical/traefik. +The ROCKs on this repository are built with [OCI Factory](https://github.com/canonical/oci-factory/), which also takes care of periodically rebuilding the images. +Automation takes care of: +* validating PRs, by simply trying to build the ROCK; +* pulling upstream releases, creating a PR with the necessary files to be manually reviewed; +* releasing to GHCR at [ghcr.io/canonical/traefik:dev](https://ghcr.io/canonical/traefik:dev), when merging to main, for development purposes. -# Manual verification: -``` -rockcraft -v - -skopeo --insecure-policy copy oci-archive:traefik_2.9.6_amd64.rock docker-daemon:trfk - -docker run --rm -p 8080:8080 trfk -``` - -cleanup: -`docker rmi -f trfk` \ No newline at end of file