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
27 changes: 27 additions & 0 deletions .github/scripts/locate_bcr_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -euo pipefail

FORK_OWNER="${REGISTRY_FORK%%/*}"
HEAD_REF="${FORK_OWNER}:periphery-${TAG_NAME}"

for attempt in 1 2 3 4 5; do
RESPONSE=$(curl --silent --show-error --location --get \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--data-urlencode "state=open" \
--data-urlencode "head=${HEAD_REF}" \
"https://api.github.com/repos/${REGISTRY}/pulls")

PR_NUMBER=$(jq --raw-output '.[0].number // empty' <<<"${RESPONSE}")
if [[ -n "${PR_NUMBER}" ]]; then
echo "number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
exit 0
fi

sleep 5
done

echo "Could not find an open pull request for ${HEAD_REF}"
exit 1
24 changes: 24 additions & 0 deletions .github/scripts/post_bcr_skip_comment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -euo pipefail

COMMENTS=$(curl --silent --show-error --location \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${REGISTRY}/issues/${PR_NUMBER}/comments")

if jq -e --arg body "${COMMENT_BODY}" '.[] | select(.body == $body)' <<<"${COMMENTS}" >/dev/null; then
echo "Comment already exists on PR #${PR_NUMBER}"
exit 0
fi

PAYLOAD=$(jq --null-input --arg body "${COMMENT_BODY}" '{body: $body}')

curl --silent --show-error --location \
--request POST \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
--data "${PAYLOAD}" \
"https://api.github.com/repos/${REGISTRY}/issues/${PR_NUMBER}/comments" >/dev/null
29 changes: 28 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,31 @@ jobs:
permissions:
contents: write
secrets:
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

skip-unstable-url:
needs: publish
if: ${{ needs.publish.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
env:
REGISTRY: bazelbuild/bazel-central-registry
REGISTRY_FORK: peripheryapp/bazel-central-registry
TAG_NAME: ${{ inputs.tag_name || github.ref_name }}
COMMENT_BODY: "@bazel-io skip_check unstable_url"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Locate BCR pull request
id: pr
env:
GITHUB_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}
run: bash .github/scripts/locate_bcr_pr.sh

- name: Post unstable URL skip comment
env:
GITHUB_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}
PR_NUMBER: ${{ steps.pr.outputs.number }}
run: bash .github/scripts/post_bcr_skip_comment.sh
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ jobs:
- name: Check generated Bazel rules
run: mise r gen-bazel-rules && git diff --quiet --exit-code
bazel:
name: Bazel (${{ matrix.os }})
name: Bazel (${{ matrix.bazel }}, ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
bazel: [8.x, 9.x]
os: [macOS, Linux]
include:
- os: macOS
Expand All @@ -44,14 +45,15 @@ jobs:
runs-on: ${{ matrix.runs-on }}
container: ${{ matrix.container }}
env:
USE_BAZEL_VERSION: ${{ matrix.bazel }}
CC: ${{ matrix.cc }}
steps:
- uses: actions/checkout@master
- uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-version: 1.x
bazelisk-cache: true
disk-cache: bazel-${{ matrix.os }}
disk-cache: bazel-${{ matrix.os }}-${{ matrix.bazel }}
repository-cache: true
- name: Scan
run: bazel run //:periphery -- scan --bazel --quiet --strict --baseline baselines/${{ matrix.baseline }}
Expand Down
Loading