Skip to content

Commit

Permalink
Rename workflows, only make policy releases on tags
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondJoseph committed Dec 12, 2023
1 parent d72da73 commit 6a9d5d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/[email protected]

- name: Setup OPA
uses: open-policy-agent/setup-opa@v2
uses: open-policy-agent/setup-opa@v2.1.0
with:
version: latest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ name: Policy Container

on:
push:
branches: # Release only when main advances
- main
pull_request:

jobs:
build_publish:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -18,9 +19,6 @@ jobs:
- name: Generate Image Name
run: echo IMAGE_REPOSITORY=ghcr.io/$(echo "${{ github.repository }}-policy" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV

- name: Generate Image Tag # :<tag> or :latest if not tagged
run: echo IMAGE_TAG=$(echo "${{ github.ref_type }} = 'tag' && ${{ github.ref_name }} || 'latest'" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV

- name: Log in to GitHub Docker Registry
uses: docker/[email protected]
with:
Expand All @@ -29,12 +27,13 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Setup OPA
uses: open-policy-agent/setup-opa@v2
uses: open-policy-agent/setup-opa@v2.1.0
with:
version: latest

- name: Build & Publish OPA Policy
run: opa build ./org-policy

- name: Publish OPA Policy
run: oras push ${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }} --config ./org-policy/config.json:application/vnd.oci.image.config.v1+json bundle.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
run: oras push ${{ env.IMAGE_REPOSITORY }}:${{ github.ref_name }} --config ./org-policy/config.json:application/vnd.oci.image.config.v1+json bundle.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip

0 comments on commit 6a9d5d4

Please sign in to comment.