Skip to content

feat(examples): add r/demo/games/tictactoe 1P-VS-CPU #52355

feat(examples): add r/demo/games/tictactoe 1P-VS-CPU

feat(examples): add r/demo/games/tictactoe 1P-VS-CPU #52355

Workflow file for this run

# This workflow must be kept in sync to some extent with bot-proxy.yml
name: GitHub Bot
on:
# Watch for changes on PR state, assignees, labels, head branch and draft/ready status
pull_request_target:
types:
- assigned
- unassigned
- labeled
- unlabeled
- opened
- reopened
- synchronize # PR head updated
- converted_to_draft
- ready_for_review
# Watch for changes on PR reviews
pull_request_review:
types: [submitted, edited, dismissed]
# Watch for changes on PR comment
issue_comment:
types: [created, edited, deleted]
# Manual run from GitHub Actions interface
workflow_dispatch:
inputs:
pull-request-list:
description: "PR(s) to process: specify 'all' or a comma separated list of PR numbers, e.g. '42,1337,7890'"
required: true
default: all
type: string
jobs:
# This job creates a matrix of PR numbers based on the inputs from the various
# events that can trigger this workflow so that the process-pr job below can
# handle the parallel processing of the pull-requests
define-prs-matrix:
name: Define PRs matrix
# Skip this workflow if:
# - the bot is not configured on this repo/fork
# - the bot is retriggering itself
# - the event is emitted by codecov
# - the event is a review on a pull request from a fork (see save-pr-number job below)
if: |
vars.GH_BOT_LOGIN != '' &&
github.actor != vars.GH_BOT_LOGIN &&
github.actor != 'codecov[bot]' &&
(github.event_name != 'pull_request_review' || github.event.pull_request.base.repo.full_name == github.event.pull_request.head.repo.full_name)
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
pr-numbers: ${{ steps.pr-numbers.outputs.pr-numbers }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get last commit hash for directory
id: get-hash
run: echo "dir_hash=$(git log -1 --format="%H" -- contribs/github-bot/)" >> $GITHUB_OUTPUT
- name: Cache github-bot binary
id: cache-bot-bin
uses: actions/cache@v4
with:
path: /usr/local/bin/github-bot
key: ${{ runner.os }}-github-bot-${{ steps.get-hash.outputs.dir_hash }}
- name: Install Go
if: steps.cache-bot-bin.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version-file: contribs/github-bot/go.mod
- name: Build github-bot binary
if: steps.cache-bot-bin.outputs.cache-hit != 'true'
working-directory: contribs/github-bot
run: go build -o /usr/local/bin/github-bot .
- name: Generate matrix from event
id: pr-numbers
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: github-bot matrix -matrix-key 'pr-numbers' -verbose
# This job is executed if an event with read-only permission has triggered this
# workflow (e.g 'pull_request_review' on a pull request opened from a fork).
# In this case, this job persists the PR number in an artifact so that the
# proxy workflow can use it to rerun the current workflow with write permission.
# See bot-proxy.yml for more info.
save-pr-number:
name: Persist PR number for proxy
# Run this job if the event is a review on a pull request opened from a fork
if: github.event_name == 'pull_request_review' && github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name
runs-on: ubuntu-latest
steps:
- name: Write PR number to a file
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: echo $PR_NUMBER > pr-number
- name: Upload it as an artifact
uses: actions/upload-artifact@v4
with:
name: pr-number
path: pr-number
# This job processes each pull request in the matrix individually while ensuring
# that a same PR cannot be processed concurrently by mutliple runners
process-pr:
name: Process PR
needs: define-prs-matrix
# Just skip this job if PR numbers matrix is empty (prevent failed state)
if: needs.define-prs-matrix.outputs.pr-numbers != '[]' && needs.define-prs-matrix.outputs.pr-numbers != ''
runs-on: ubuntu-latest
strategy:
matrix:
# Run one job for each PR to process
pr-number: ${{ fromJSON(needs.define-prs-matrix.outputs.pr-numbers) }}
concurrency:
# Prevent running concurrent jobs for a given PR number
group: ${{ matrix.pr-number }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get last commit hash for directory
id: get-hash
run: echo "dir_hash=$(git log -1 --format="%H" -- contribs/github-bot/)" >> $GITHUB_OUTPUT
- name: Cache github-bot binary
id: cache-bot-bin
uses: actions/cache@v4
with:
path: /usr/local/bin/github-bot
key: ${{ runner.os }}-github-bot-${{ steps.get-hash.outputs.dir_hash }}
- name: Install Go
if: steps.cache-bot-bin.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version-file: contribs/github-bot/go.mod
- name: Build github-bot binary
if: steps.cache-bot-bin.outputs.cache-hit != 'true'
working-directory: contribs/github-bot
run: go build -o /usr/local/bin/github-bot .
- name: Run GitHub Bot
working-directory: contribs/github-bot
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_PAT }}
run: github-bot check -pr-numbers '${{ matrix.pr-number }}' -verbose