Skip to content
Closed
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
20 changes: 11 additions & 9 deletions .github/workflows/build-ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ on:
- main
- v2
paths:
- 'gen.Dockerfile'
- '.github/workflows/build-ci-image.yml'
pull_request:
- "gen.Dockerfile"
- ".github/workflows/build-ci-image.yml"
pull_request_target:
paths:
- 'gen.Dockerfile'
- '.github/workflows/build-ci-image.yml'
- "gen.Dockerfile"
- ".github/workflows/build-ci-image.yml"
workflow_dispatch:
inputs:
force_rebuild:
description: 'Force rebuild of the image'
description: "Force rebuild of the image"
required: false
default: 'false'
default: "false"

env:
REGISTRY: ghcr.io
Expand All @@ -37,6 +37,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -68,7 +70,7 @@ jobs:
- name: Set image tag output
id: set-tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
if [ "${{ github.event_name }}" == "pull_request_target" ] || [ "${{ github.event_name }}" == "pull_request" ]; then
echo "tag=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" == "refs/heads/v2" ]; then
echo "tag=v2" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -104,7 +106,7 @@ jobs:
run: echo "Image built with digest ${{ steps.meta.outputs.digest }}"

- name: Comment on PR with image tag
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request_target' || github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/check-generate.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check Generated Files

on:
pull_request:
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
Expand All @@ -11,11 +11,14 @@ jobs:
contents: read
actions: read
packages: read
issues: read
outputs:
image: ${{ steps.docker-image.outputs.image }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Determine Docker image
id: docker-image
Expand Down Expand Up @@ -48,14 +51,20 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build-ci-image.yml',
event: 'pull_request',
event: 'pull_request_target',
per_page: 10
});

// Find the run for this PR
const prRun = runs.workflow_runs.find(run =>
run.head_sha === context.payload.pull_request.head.sha
);
// For pull_request_target from forks, run.pull_requests is always empty (GitHub API limitation).
// Fall back to matching by head_sha for fork PRs.
const prNumber = context.issue.number;
const prHeadSha = context.payload.pull_request.head.sha;
const prRun = runs.workflow_runs.find(run => {
if (Array.isArray(run.pull_requests) && run.pull_requests.length > 0) {
return run.pull_requests.some(pr => pr.number === prNumber);
}
return run.head_sha === prHeadSha;
});

if (prRun) {
console.log(`Found workflow run: ${prRun.html_url}`);
Expand Down Expand Up @@ -95,6 +104,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Cache cargo artifacts
uses: actions/cache@v4
Expand Down Expand Up @@ -139,6 +150,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run go mod tidy and check
run: |
Expand All @@ -158,6 +171,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run mockery and check
run: |
Expand Down
2 changes: 1 addition & 1 deletion gen.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ FROM alpine:latest AS buf-downloader
ARG TARGETARCH
ARG BUF_VERSION
RUN apk add --no-cache curl tar
RUN BUFARCH=$(case ${TARGETARCH} in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \
RUN if [ "${TARGETARCH}" = "arm64" ]; then BUFARCH="aarch64"; else BUFARCH="x86_64"; fi && \
curl -fsSL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-Linux-${BUFARCH}.tar.gz" | \
tar -xzC /tmp

Expand Down
Loading