Skip to content

Commit

Permalink
build: Fine-tune build triggers. (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-todorov committed Jul 11, 2023
1 parent ff7d3a3 commit 4cbffaa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ on:

# On push event
push:
# Build only changes pushed into the `master` branch.
#branches:
# - master
# - pipeline
# Build only changes pushed into the `master` branch -- avoids double builds when you push in a branch which has a PR.
branches:
- master
- pipeline
# Ignore documentation changes (Netlify will handle this)
paths-ignore:
- 'docs/**'
Expand All @@ -39,7 +39,7 @@ on:
# Currently you cannot use ${{ env.IS_FORK }} for some reason, which is why you might need to copy-paste some of these.
env:
REPOSITORY: ${{ github.repository }}
IS_FORK: ${{ github.repository != vars.CURRENT_REPO }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != vars.CURRENT_REPO || github.repository != vars.CURRENT_REPO }}
IS_PR: ${{ github.event_name == 'pull_request' }}
EVENT_NAME: ${{ toJSON(github.event_name) }}
# format: username:branch
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ on:
- '*.md'
- '**/*.md'
- '.github/workflows/bump*.yaml'
- '.github/workflows/docs.yaml'
- '.github/workflows/command-*.yaml'
- '.github/workflows/clear-cache.yaml'
- '.github/workflows/deploy-tag.yaml'
- '.github/workflows/prepare-release.yaml'
pull_request:
Expand All @@ -21,7 +23,9 @@ on:
- '*.md'
- '**/*.md'
- '.github/workflows/bump*.yaml'
- '.github/workflows/docs.yaml'
- '.github/workflows/command-*.yaml'
- '.github/workflows/clear-cache.yaml'
- '.github/workflows/deploy-tag.yaml'
- '.github/workflows/prepare-release.yaml'

Expand Down
15 changes: 12 additions & 3 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@ name: Build docs
on:
# Build PRs
pull_request_target:
types: [ opened, synchronize, reopened ]
paths:
- 'docs/**'
- '.github/workflows/docs.yaml'

# On push event
push:
# Build only changes pushed into the `master` branch -- avoids double builds when you push in a branch which has a PR.
branches:
- master
- pipeline
paths:
- 'docs/**'
- '.github/workflows/docs.yaml'

workflow_dispatch:

permissions:
statuses: write

env:
REPOSITORY: ${{ github.repository }}
IS_FORK: ${{ github.repository != vars.CURRENT_REPO }}
IS_FORK: ${{ github.event.pull_request.head.repo.full_name != vars.CURRENT_REPO || github.repository != vars.CURRENT_REPO }}
IS_PR: ${{ github.event_name == 'pull_request' }}
EVENT_NAME: ${{ toJSON(github.event_name) }}
# format: username:branch
Expand Down Expand Up @@ -47,7 +55,8 @@ jobs:
run: |
npm install -g netlify
is_master=${{ github.ref_name == 'master' }}
[[ "$is_master" == "true" ]] && args=" --prod "
is_fork=${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != vars.CURRENT_REPO && 'true' || 'false' }}
[[ "$is_master" == "true" && "$is_fork" == "false" ]] && args=" --prod "
netlify deploy -d site/ $args | tee build.log
url=$(cat build.log | grep -iE "website(.+)url" | cut -f 2- -d":" | xargs)
echo "Url: $url"
Expand All @@ -59,7 +68,7 @@ jobs:
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: Build docs / docs / netlify preview
owner: ${{ vars.ORIGIN_OWNER }}
repository: ${{ vars.CURRENT_REPO }}
state: ${{ job.status }}
sha: ${{ github.event.pull_request.head.sha || github.sha }}
target_url: ${{ steps.publish.outputs.url }}
Expand Down

0 comments on commit 4cbffaa

Please sign in to comment.