Skip to content
Open
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
52 changes: 32 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
# This is a basic workflow to help you get started with Actions

name: Test Checks
name: Mergeability Checks

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
#push:
# branches: [ master ]
# Triggers the workflow on pull request events but only for the master branch
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
check:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

- name: Check if PR is mergeable
id: isMergeable
uses: actions/github-script@v5
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB-TOKEN: ${{ secrets.GITHUB_TOKEN }}
script: |
console.log(context.payload.pullrequest)
const org = context.payload.organization.login
const repo = context.payload.repository.name
const params = {
owner: org,
repo,
pull_number: context.payload.pull_request.number
}
try {
const res = await github.rest.pulls.get(params)
if (res.data.mergeable === true) {
console.log("This PR is mergeable")
} else {
console.log(`This PR is not mergeable ${JSON.stringify(res.data)}`)
}
} catch (e) {
if (e.status === 404) {
const message404 = `No PR found for ${JSON.stringify(params)}`
core.debug(message404)
core.setOutput('status', message404)
core.setFailed(`${message404}`)
throw new Error(message404)
}
const message = `${e} fetching the PR with ${JSON.stringify(params)}`
core.debug(message)
core.setOutput('status', message)
core.setFailed(`${message}`)
throw new Error(message)
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tic Tac Toe Game

Learn GitHub Actions through a fun little game.
Learn GitHub Actions through a fun little game.