Skip to content

Commit

Permalink
Merge pull request #170 from MetRonnie/actions
Browse files Browse the repository at this point in the history
GH Actions: prevent update_copyright workflow running on forks
  • Loading branch information
wxtim authored Jan 6, 2021
2 parents 617f717 + 9477eb7 commit 831a528
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions .github/workflows/update_copyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,19 @@ on:

jobs:
update-copyright:
if: github.repository_owner == 'cylc'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:

- name: Checkout repo
uses: actions/checkout@v2

- name: Configure git
uses: cylc/release-actions/configure-git@v1

- name: Checkout PR branch
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
year=$(date '+%Y' --utc)
branch_name="copyright-${year}"
git checkout -b "$branch_name"
echo "YEAR=$year" >> $GITHUB_ENV
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
uses: cylc/release-actions/checkout-copyright-branch@v1

- name: Update copyright year
env:
Expand All @@ -53,16 +50,10 @@ jobs:
git push origin "$BRANCH_NAME"
- name: Create pull request
uses: cylc/release-actions/create-pr@v1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -X POST \
https://api.github.com/repos/${{ github.repository }}/pulls \
-H "authorization: Bearer ${GH_TOKEN}" \
-H 'content-type: application/json' \
--data '{
"title": "Auto PR: update copyright year",
"head": "${{ env.BRANCH_NAME }}",
"base": "master",
"body": "Happy new year!"
}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
head: ${{ env.BRANCH_NAME }}
title: 'Auto PR: update copyright year'
body: 'Happy new year!'

0 comments on commit 831a528

Please sign in to comment.