Skip to content

Commit

Permalink
Fix github status checks when submitting PR from fork (compdemocracy#520
Browse files Browse the repository at this point in the history
)

* Fixed depcheck workflow issue.

* Run lint on all PRs.

* Try fixing depcheck.

* Trying to skip steps by checking secret value.

* Try using set-env to tell depcheck when secrets available.

* Trying new way to get depcheck working on fork.

* One more thing.
  • Loading branch information
patcon authored Aug 12, 2020
1 parent c56b269 commit 212f811
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/depcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
CI_COMMIT_ID: ${{ github.event.pull_request.head.sha || github.sha }}
CI_REPO_NAME: ${{ github.repository }}
steps:
# See: https://github.community/t/if-expression-with-context-variable/16558/6
- name: Check if secrets available
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
unset HAS_SECRET
if [ -n "$GITHUB_TOKEN" ]; then HAS_SECRET=true; fi
echo ::set-env name=HAS_SECRET::${HAS_SECRET}
- name: Use Node.js
uses: actions/[email protected]
with:
Expand All @@ -24,6 +33,7 @@ jobs:
run: npm install -g commit-status

- name: Initiate commit status placeholders
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
# commit-status <state> <context> <description> <link>
commit-status pending "DepCheck / dependencies" "Detecting unused packages..."
Expand Down Expand Up @@ -57,6 +67,7 @@ jobs:
echo ::set-output name=devdependencies::$(cat .results.json | jq '.devDependencies | join(", ") | .[:139]' --raw-output)
- name: Set commit status messages and success states
if: github.event.pull_request.head.repo.full_name == github.repository
run: |
if [ "${{ steps.depcheck.outputs.dependencies }}" = "" ]; then
commit-status success "DepCheck / dependencies" "No unused packages detected."
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Lint

on:
pull_request:
types: ["opened", "reopened", "synchronize"]

jobs:
eslint:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- uses: actions/[email protected]

Expand Down

0 comments on commit 212f811

Please sign in to comment.