Skip to content

Commit

Permalink
Add the Alertmanager ROCK to OCI Factory (#12)
Browse files Browse the repository at this point in the history
* prepare repo for oci-factory

* add workflow to open PRs to oci-factory as a test

* build rock 0.24 to trigger new CI on 0.25

* enable manual action for release to oci-factory as a test

* return to build 0.25

* add badge for future oci-releases

* use workflow from main

* fix alertmanager link in README
  • Loading branch information
lucabello authored Aug 16, 2023
1 parent fd15b5b commit c2e919a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 42 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/build-rock.yaml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/workflows/rock-release-dev.yaml
Original file line number Diff line number Diff line change
@@ -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: alertmanager
13 changes: 13 additions & 0 deletions .github/workflows/rock-release-oci-factory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Open a PR to OCI Factory

on:
workflow_dispatch: {} # TODO: Test to see if this works
push:
branches:
- main

jobs:
build:
uses: canonical/observability/.github/workflows/rock-release-oci-factory.yaml@main
with:
rock-name: alertmanager
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
uses: canonical/observability/.github/workflows/update-rock.yaml@main
uses: canonical/observability/.github/workflows/rock-update.yaml@main
with:
rock-name: alertmanager
source-repo: prometheus/alertmanager
Expand Down
File renamed without changes.
File renamed without changes.
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
# alertmanager-rock

[![Build ROCK](https://github.com/canonical/alertmanager-rock/actions/workflows/build-rock.yaml/badge.svg)](https://github.com/canonical/alertmanager-rock/actions/workflows/build-rock.yaml)
[![Open a PR to OCI Factory](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-release-oci-factory.yaml/badge.svg)](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-release-oci-factory.yaml)
[![Publish to GHCR:dev](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-release-dev.yaml/badge.svg)](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-release-dev.yaml)
[![Update ROCK](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-update.yaml/badge.svg)](https://github.com/canonical/alertmanager-rock/actions/workflows/rock-update.yaml)

Build an alertmanager image using
[rockcraft](https://github.com/canonical/rockcraft), maintaining the same file
hierarchy as the
[`prometheus/alertmanager`](https://github.com/prometheus/alertmanager/blob/main/Dockerfile)
image.
[ROCKs](https://canonical-rockcraft.readthedocs-hosted.com/en/latest/) for [Alertmanager](https://prometheus.io/docs/alerting/latest/alertmanager/).
This repository holds all the necessary files to build ROCKs for the upstream versions we support. The Alertmanager ROCK is used by the [alertmanager-k8s-operator](https://github.com/canonical/alertmanager-k8s-operator) charm.

## Usage
```shell
rockcraft pack -v
```
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.

## Manual verification
```shell
tar tf alertmanager_0.24.0_amd64.rock
tar -O -xf alertmanager_0.24.0_amd64.rock oci-layout
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/alertmanager:dev](https://ghcr.io/canonical/alertmanager:dev), when merging to main, for development purposes.

skopeo --insecure-policy copy oci-archive:alertmanager_0.24.0_amd64.rock docker-daemon:alertmanager:0.24.0
dive alertmanager:0.24.0

docker run --rm -d -p 9093:9093 alertmanager:0.24.0
curl localhost:9093/api/v1/alerts
```

## Build automation
This repo has workflows in place to:
- update `rockcraft.yaml` when new versions of alertmanager are published;
- publish a new rock on every merge.

0 comments on commit c2e919a

Please sign in to comment.