Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
branches: [main]
jobs:
test:
runs-on: [self-hosted, Linux, X64]
runs-on: ubuntu-latest
steps:
Comment thread
intel352 marked this conversation as resolved.
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go build ./...
- run: go test ./... -v -race -count=1

wfctl-strict-contracts:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
96 changes: 76 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v6
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@v7
Expand All @@ -20,38 +20,94 @@
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Sync manifest to registry
if: success() && env.GH_TOKEN != ''
continue-on-error: true

publish-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [release]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Publish GitHub release
uses: actions/github-script@v7
with:
github-token: ${{ github.token }}
script: |
const tag = process.env.GITHUB_REF_NAME;
const { owner, repo } = context.repo;
let release;
try {
({ data: release } = await github.rest.repos.getReleaseByTag({ owner, repo, tag }));
} catch (error) {
if (error.status === 404) {
core.setFailed(`No GitHub release found for ${tag}; ensure GoReleaser created the draft before publishing.`);
return;
}
throw error;
}
if (release.draft) {
await github.rest.repos.updateRelease({
owner,
repo,
release_id: release.id,
draft: false,
});
}

sync-registry:
if: startsWith(github.ref, 'refs/tags/v')
needs: [publish-release]
continue-on-error: true
Comment thread
intel352 marked this conversation as resolved.
runs-on: ubuntu-latest
steps:
- name: Check registry token
id: registry-token
env:
GH_TOKEN: ${{ secrets.REGISTRY_PAT }}
REGISTRY_PAT: ${{ secrets.REGISTRY_PAT }}
run: |
if [ -n "$REGISTRY_PAT" ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
fi

- name: Check out plugin
if: steps.registry-token.outputs.present == 'true'
uses: actions/checkout@v4
with:
path: plugin

- name: Check out workflow-registry
if: steps.registry-token.outputs.present == 'true'
uses: actions/checkout@v4
with:
repository: GoCodeAlone/workflow-registry
token: ${{ secrets.REGISTRY_PAT }}
path: workflow-registry

- name: Update workflow-registry manifest
if: steps.registry-token.outputs.present == 'true'
run: |
git clone https://x-access-token:${GH_TOKEN}@github.com/GoCodeAlone/workflow-registry.git /tmp/registry
mkdir -p /tmp/registry/plugins/okta
registry_dir="$GITHUB_WORKSPACE/workflow-registry"
mkdir -p "$registry_dir/plugins/okta"
TAG=${GITHUB_REF#refs/tags/}
VERSION=${TAG#v}
jq --arg v "$VERSION" '.version = $v' plugin.json > /tmp/registry/plugins/okta/manifest.json
cd /tmp/registry
jq --arg v "$VERSION" --arg tag "$TAG" '
.version = $v |
.downloads = ((.downloads // []) | map(.url |= sub("/releases/download/v[^/]+/"; "/releases/download/" + $tag + "/")))
' "$GITHUB_WORKSPACE/plugin/plugin.json" > "$registry_dir/plugins/okta/manifest.json"
cd "$registry_dir"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add plugins/okta/manifest.json
git diff --cached --quiet || git commit -m "chore: sync okta plugin manifest v${VERSION}"
git push

notify-registry:
if: startsWith(github.ref, 'refs/tags/v')
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Notify workflow-registry
if: env.GH_TOKEN != ''
if: steps.registry-token.outputs.present == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REGISTRY_PAT }}
repository: GoCodeAlone/workflow-registry
event-type: plugin-release
client-payload: >-
{"plugin": "${{ github.repository }}", "tag": "${{ github.ref_name }}"}
env:
GH_TOKEN: ${{ secrets.REGISTRY_PAT }}
continue-on-error: true

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ archives:
checksum:
name_template: checksums.txt
release:
draft: true
github:
owner: GoCodeAlone
name: workflow-plugin-okta
Loading