Skip to content

Commit

Permalink
Merge pull request #367 from JohnTitor/gha
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Jul 21, 2022
2 parents 3350bad + 8485f3f commit d5f8df3
Show file tree
Hide file tree
Showing 4 changed files with 2,542 additions and 36 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/checks.yml
@@ -1,14 +1,15 @@
name: Check chagnes
name: Check changes

on: [pull_request]

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "12.x"
node-version: 16
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm run lint
20 changes: 10 additions & 10 deletions .github/workflows/non-bot-check.yml
Expand Up @@ -8,12 +8,12 @@ jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@0.9.0
- uses: actions/github-script@v6.1.0
id: comment
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: return context.payload.issue.pull_request && context.payload.comment.body === '/check'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
if: steps.comment.outputs.result == 'true'
- name: Checkout Git Branch
if: steps.comment.outputs.result == 'true'
Expand All @@ -23,44 +23,44 @@ jobs:
- name: Comment for non-GitHub Bot PRs
id: non-bot-check
if: steps.comment.outputs.result == 'true'
uses: actions/github-script@0.9.0
uses: actions/github-script@v6.1.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: { merge_commit_sha, user: { login }} } = await github.pulls.get({
const { data: { merge_commit_sha, user: { login }} } = await github.rest.pulls.get({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
console.log(`PR created by ${login}`);
if (login !== 'github-actions[bot]') {
const { data: { files }} = await github.repos.getCommit({
const { data: { files }} = await github.rest.repos.getCommit({
ref: merge_commit_sha,
owner: context.repo.owner,
repo: context.repo.repo,
});
const protectedFiles = files.filter(({ filename }) => /^spec\//.test(filename))
if (protectedFiles && protectedFiles.length) {
await github.issues.createComment({
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Thank you for contribution!\nSeems like you trying to change specification not in a right place :thinking:\nThis repository contains code for website [semver.org](https://semver.org) with spec translations. If you looking for direct changes to SemVer, please use [semver/semver](https://github.com/semver/semver) repository.\n\nPlease close this PR and create a new one to the right repository. If you have any questions, feel free to ping someone from @semver/maintainers'
body: 'Thank you for contribution!\nSeems like you trying to change specification not in a right place :thinking:\nThis repository contains code for website [semver.org](https://semver.org) with spec translations. If you are looking for direct changes to SemVer, please use [semver/semver](https://github.com/semver/semver) repository.\n\nPlease close this PR and create a new one to the right repository. If you have any questions, feel free to ping someone from @semver/maintainers'
});
const comments = protectedFiles.map(({ filename }) => ({
"path": filename,
"position": 1,
"body": "This file shouldn't be changed in this repo"
}))
await github.pulls.createReview({
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
event: 'REQUEST_CHANGES',
comments
})
} else {
await github.pulls.createReview({
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
Expand Down
16 changes: 5 additions & 11 deletions .github/workflows/sync.yml
Expand Up @@ -10,27 +10,21 @@ jobs:
if: github.repository == 'semver/semver.org'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: "12.x"
node-version: 16
cache: 'npm'

- name: Cache node modules
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install
run: npm ci

- name: Collect latest releases
run: npm run collect

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v4.0.4
with:
commit-message: 'feat: Updated SemVer spec'
title: Original specification updates
Expand Down

0 comments on commit d5f8df3

Please sign in to comment.