Manifest V3 #87
Workflow file for this run
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 IITC Button | |
# read-only repo token | |
# no access to secrets | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
pull_request: | |
paths-ignore: | |
- '!.github/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: npm ci | |
- name: Linter | |
run: npm run lint | |
- name: Build | |
run: npm run build | |
- name: Get version from package.json | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: polyseam/get-version-key-from-json@v1.0.0 | |
id: get-version-key-from-json | |
with: | |
path-to-json: './package.json' | |
- name: Save metadata | |
run: | | |
mkdir -p ./build/.metadata | |
if [ "$GITHUB_EVENT_NAME" = "push" ]; then | |
if [[ "$GITHUB_REF" =~ ^refs/tags/ ]]; then | |
mv artifacts/*.zip ./build/iitc-button-${{steps.get-version-key-from-json.outputs.version}}.zip | |
echo "release" > ./build/.metadata/build_type | |
else | |
# Beta build from master branch | |
mv artifacts/*.zip ./build/iitc-button-${{github.sha}}.zip | |
echo "beta" > ./build/.metadata/build_type | |
fi | |
echo ${{ github.sha }} > ./build/.metadata/commit | |
elif [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
mv artifacts/*.zip ./build/iitc-button-${{github.event.pull_request.head.sha}}.zip | |
echo "PR" > ./build/.metadata/build_type | |
echo ${{ github.event.pull_request.head.sha }} > ./build/.metadata/commit | |
fi | |
echo $( ls ./build/ | grep '.zip' ) > ./build/.metadata/zip_filename | |
echo "GITHUB_SHA_SHORT=$(cat ./build/.metadata/commit | cut -c 1-6)" >> $GITHUB_ENV | |
- uses: ncipollo/release-action@v1 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
allowUpdates: true | |
artifactErrorsFailBuild: true | |
artifacts: "./build/iitc-button-${{ steps.get-version-key-from-json.outputs.version }}.zip" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: iitc-button-${{ env.GITHUB_SHA_SHORT }}-artifact | |
path: | | |
./build/ |