[HEAD] New article #82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: preview PR | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- closed | |
paths: | |
- source/** | |
- .github/workflows/preview.yml | |
concurrency: preview-${{ github.ref }} | |
jobs: | |
deploy-preview: | |
if: github.repository == 'croque-scp/scp' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine changed projects | |
id: changes | |
run: | | |
CHANGED_PROJECTS=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD -- 'source/*' | cut -d/ -f2 | sort -u) | |
echo "CHANGED_PROJECTS=$CHANGED_PROJECTS" >> $GITHUB_ENV | |
- name: Install & build changed projects | |
run: | | |
mkdir dist | |
for project in $CHANGED_PROJECTS; do | |
pushd source/$project | |
npm install | |
npm run build | |
popd | |
cp -r source/$project/dist dist/$project | |
done | |
- name: Deploy preview | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
source-dir: dist |