Bump actions/setup-node from 2 to 4 #281
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 and Publish | |
on: | |
push: | |
release: | |
types: [published] | |
jobs: | |
check: | |
name: Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Lint | |
run: | | |
npm run lint | |
- name: Build | |
run: | | |
cat << CONFIG > src/config/config.json | |
{ | |
"hostname": "box.example.com", | |
"mockApi": true | |
} | |
CONFIG | |
npm run build | |
publish: | |
needs: [check] | |
name: Publish | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: | | |
npm install | |
- name: Build dist | |
run: | | |
cat << CONFIG > src/config/config.json | |
{ | |
"hostname": "/", | |
"mockApi": false | |
} | |
CONFIG | |
PUBLIC_URL=/admin/ npm run build | |
mv build dist | |
- name: Build demo | |
run: | | |
cat << CONFIG > src/config/config.json | |
{ | |
"hostname": "box.example.com", | |
"mockApi": true | |
} | |
CONFIG | |
PUBLIC_URL=/mailinabox-ui/ npm run build | |
- name: Create dist archives | |
id: archives | |
run: | | |
tag=${GITHUB_REF#refs/tags/} | |
tar_archive="mailinabox-ui.$tag.tar.gz" | |
zip_archive="mailinabox-ui.$tag.zip" | |
tar -czf "$tar_archive" dist/ | |
zip -r9 "$zip_archive" dist/ | |
echo "::set-output name=tar_archive::$tar_archive" | |
echo "::set-output name=zip_archive::$zip_archive" | |
- name: Get release | |
id: get_release | |
uses: bruceadams/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload release tar archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release.outputs.upload_url }} | |
asset_path: ${{ steps.archives.outputs.tar_archive }} | |
asset_name: ${{ steps.archives.outputs.tar_archive }} | |
asset_content_type: application/tar+gzip | |
- name: Upload release zip archive | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release.outputs.upload_url }} | |
asset_path: ${{ steps.archives.outputs.zip_archive }} | |
asset_name: ${{ steps.archives.outputs.zip_archive }} | |
asset_content_type: application/zip | |
- name: Publish demo | |
run: | | |
mv build .build | |
tag=${GITHUB_REF#refs/tags/} | |
git fetch | |
git checkout gh-pages | |
rm -rf * | |
mv .build/* . | |
rm -rf .build | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "Add build for version $tag" | |
git push |