chore: fix deploy #739
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: Build | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
branches: | |
- master | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
with: | |
submodules: true | |
- uses: actions/setup-node@v3.6.0 | |
with: | |
node-version: 16.x | |
cache: 'yarn' | |
- name: Install | |
run: yarn install --frozen-lockfile | |
- name: Test | |
run: yarn test | |
build: | |
runs-on: ubuntu-latest | |
needs: [unit-tests] | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- uses: actions/setup-node@v3.6.0 | |
with: | |
node-version: 16.x | |
cache: 'yarn' | |
- name: Install | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
- name: Archive build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bundle | |
path: dist | |
action-tests: | |
runs-on: ubuntu-latest | |
needs: [build] | |
strategy: | |
matrix: | |
include: | |
- branch: test/test-a-affected | |
workspace: test-a | |
base: master | |
affected: true | |
- branch: test/test-a-affected | |
workspace: test-a | |
base: master | |
pattern: '*.ts' | |
affected: false | |
- branch: test/test-a-affected | |
workspace: test-a | |
base: master | |
pattern: 'src/**' | |
affected: true | |
- branch: test/test-a-affected | |
workspace: test-b | |
base: master | |
affected: false | |
- branch: test/tags | |
workspace: test-a | |
base: test-tag | |
affected: true | |
- branch: test/tags | |
workspace: test-b | |
base: test-tag | |
affected: false | |
- branch: test/dependency-affected | |
workspace: test-c | |
base: master | |
affected: true | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: bundle | |
path: dist | |
- name: Checkout test repository | |
uses: actions/checkout@v3.5.2 | |
with: | |
repository: neoxia/test-is-workspace-affected | |
path: test-repo | |
ref: ${{ matrix.branch }} | |
- name: Test action | |
id: affected | |
uses: ./ | |
with: | |
project-root: test-repo | |
workspace: ${{ matrix.workspace }} | |
base: ${{ matrix.base }} | |
pattern: ${{ matrix.pattern }} | |
- name: Should be affected | |
if: ${{ matrix.affected && !steps.affected.outputs.affected }} | |
run: | | |
echo "::error::Test failed: workspace ${{ matrix.workspace }} should be affected" | |
exit 1 | |
- name: Should not be affected | |
if: ${{ !matrix.affected && steps.affected.outputs.affected }} | |
run: | | |
echo "::error::Test failed: workspace ${{ matrix.workspace }} should not be affected" | |
exit 1 | |
deploy: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: [action-tests] | |
environment: master | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3.5.2 | |
with: | |
token: ${{ secrets.PUSH_TOKEN }} | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: bundle | |
path: dist | |
- name: Commit bundle files | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
if `git diff --quiet --exit-code` | |
then | |
echo "Nothing changed !" | |
else | |
git add dist | |
git commit -m "Automatic build" | |
git push | |
fi |