Skip to content

Commit

Permalink
Publish plugin to ghcr.io (#80)
Browse files Browse the repository at this point in the history
Adds workflow for main branch that publishes plugin to ghcr.io

* remove '-v2' from plugin script, to enable publishing to ghcr
* Workflow should build releases when tags are pushed
* add workflow for post merge with mutable tag edge

Signed-off-by: Lars Haugan <[email protected]>
  • Loading branch information
larhauga authored Nov 20, 2023
1 parent 98ac3f4 commit aac1037
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Post Merge

on:
push:
branches:
- main

jobs:
build:
name: Build edge
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish docker plugin
env:
REPO: ghcr.io/${{ github.repository }}
VERSION: edge
run: |-
make plugin
docker plugin push "$REPO:${TAG_NAME}"
38 changes: 38 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Release

on:
push:
tags:
- v*

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set TAG_NAME in Environment
# Subsequent jobs will be have the computed tag name
run: echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and publish docker plugin
env:
REPO: ghcr.io/${{ github.repository }}
VERSION: ${{ env.TAG_NAME }}
run: |-
make plugin
docker plugin push "$REPO:${TAG_NAME}"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
VERSION ?= 0.8
GO_VERSION := 1.19.1
GOLANGCI_LINT_VERSION := v1.49.0
REPO := openpolicyagent/opa-docker-authz
REPO := openpolicyagent/opa-docker-authz-v2

all: build

Expand Down
6 changes: 3 additions & 3 deletions plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ docker image build -t rootfsimage .
id=`docker container create rootfsimage true`
docker container export "$id" | tar -x -C ./rootfs

echo "Creating plugin "${REPO}-v2:${VERSION}" ..."
docker plugin create "${REPO}-v2:${VERSION}" .
echo "Creating plugin "${REPO}:${VERSION}" ..."
docker plugin create "${REPO}:${VERSION}" .

echo "Cleanup..."
docker container rm -f "$id" > /dev/null
docker image rm -f rootfsimage > /dev/null
rm -rf ./rootfs
rm -rf ./rootfs

0 comments on commit aac1037

Please sign in to comment.