chore(go.mod): use semver for go versions (1.24.0) #232
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Sync | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: "PR Number" | |
| required: true | |
| type: number | |
| jobs: | |
| pr-sync: | |
| name: PR Sync | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: alpine:3.21@sha256:b6a6be0ff92ab6db8acd94f5d1b7a6c2f0f5d10ce3c24af348d333ac6da80685 | |
| steps: | |
| - name: Install git | |
| run: apk add --no-cache git | |
| shell: sh | |
| - name: Checkout | |
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 | |
| - name: Install Required Tools | |
| shell: sh | |
| run: | | |
| __LIB_DIR="./scripts" | |
| . "${__LIB_DIR}/lib.sh" | |
| apk update | |
| apk add --no-cache \ | |
| curl \ | |
| github-cli | |
| require_cmds curl gh | |
| - name: Determine PR Number | |
| id: pr-number | |
| shell: sh | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| max_attempts: 5 # Maximum attempts to find the PR number | |
| sleep_time: 3 # Time to wait between attempts in seconds | |
| run: | | |
| __LIB_DIR="./scripts" | |
| . "${__LIB_DIR}/lib.sh" | |
| if ! git config --global --add safe.directory "${GITHUB_WORKSPACE}"; then | |
| die "Failed to add safe.directory to git config." | |
| fi | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| num="${{ github.event.inputs.pr_number }}" | |
| else | |
| commit_sha=$(git rev-parse HEAD) | |
| if [ -z "${commit_sha}" ]; then | |
| die "Failed to get the current commit SHA." | |
| fi | |
| # Try up to 5 times to find the merged PR for this commit. | |
| attempts=0 | |
| info "Searching for merged PR number for commit: ${commit_sha}" | |
| while [ "${attempts}" -lt "${max_attempts}" ]; do | |
| num=$( | |
| gh pr list \ | |
| --state merged \ | |
| --search "${commit_sha}" \ | |
| --json number \ | |
| --jq '.[0].number' | |
| ) || true | |
| if [ -n "${num}" ]; then | |
| break | |
| fi | |
| attempts=$((attempts + 1)) | |
| if [ "${attempts}" -lt "${max_attempts}" ]; then | |
| sleep "${sleep_time}" | |
| info "Attempt ${attempts} failed, retrying..." | |
| fi | |
| done | |
| if [ -z "${num}" ]; then | |
| die "No merged PR number found for this commit after ${max_attempts} attempts." | |
| fi | |
| fi | |
| info "Found PR number: ${num}" | |
| echo "pr_number=${num}" >> "${GITHUB_OUTPUT}" | |
| - name: Sync PR | |
| shell: sh | |
| env: | |
| max_attempts: 5 # Maximum attempts to sync the PR | |
| timeout: 3 # Maximum time for each curl request in seconds | |
| sleep_time: 1 # Time to wait between attempts in seconds | |
| run: | | |
| __LIB_DIR="./scripts" | |
| . "${__LIB_DIR}/lib.sh" | |
| attempts=0 | |
| while [ "${attempts}" -lt "${max_attempts}" ]; do | |
| if curl --max-time "${timeout}" \ | |
| -X POST "${{ secrets.PRIV_SYNC_WORKFLOW_URL }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| -H "Authorization: Bearer ${{ secrets.PRIV_PAT }}" \ | |
| -d "{\"ref\": \"main\", \"inputs\": {\"oss_pr_number\": \"${{ steps.pr-number.outputs.pr_number }}\"}}"; then | |
| break | |
| fi | |
| attempts=$((attempts + 1)) | |
| if [ "${attempts}" -lt "${max_attempts}" ]; then | |
| sleep "${sleep_time}" | |
| info "Attempt ${attempts} failed, retrying..." | |
| fi | |
| done | |
| if [ "${attempts}" = "${max_attempts}" ]; then | |
| die "Failed to POST request to sync PR after ${max_attempts} attempts." | |
| fi | |
| info "PR sync request sent successfully." |