Merge pull request #69 from DeskproApps/bump-dependancies-for-security #66
Workflow file for this run
This file contains hidden or 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: Branch Build | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| deskpro_app_test_and_build: | |
| permissions: | |
| contents: write | |
| name: Test / Build | |
| timeout-minutes: 30 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: git fetch --no-tags --depth=1 origin master | |
| - name: Clone repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prep local dev | |
| run: | | |
| touch ~/.gitconfig | |
| mkdir ~/.ssh | |
| git config --global user.name "$(git log -1 --pretty=format:%an)" | |
| git config --global user.email "$(git log -1 --pretty=format:%ae)" | |
| - name: Export PR Labels | |
| id: extract_labels | |
| run: echo "labels=$(jq -r '[.[] | .name] | join(",")' <<< '${{ toJson(github.event.pull_request.labels) }}')" >> $GITHUB_OUTPUT | |
| - name: Lint, Test, Build, and Tag | |
| uses: devcontainers/ci@v0.3 | |
| env: | |
| LABELS: "${{ steps.extract_labels.outputs.labels }}" | |
| with: | |
| env: LABELS | |
| runCmd: | | |
| set -e | |
| # Lint | |
| pnpm run lint | |
| pnpm tsc --noemit | |
| # Test | |
| pnpm test:coverage | |
| # Build | |
| pnpm run build | |
| # Tag | |
| if [ "$(git log -1 --pretty=format:%ae)" = "noreply@github.com" ]; then | |
| echo "Skipping workflow run because previous commit was made by workflow." | |
| exit 0 | |
| fi | |
| ## Get current version number | |
| PREV_COMMIT=$(git log -1 --pretty=format:%H -- manifest.json) | |
| VERSION=$(git show $PREV_COMMIT:manifest.json | grep version | head -n 1 | awk -F'"' '{print $4}') | |
| ## Get the commit message | |
| MILESTONE=$(echo "$LABELS" | grep -E 'major-version|minor-version' | head -1) | |
| echo "Current Version is $VERSION and the milestone is $MILESTONE" | |
| if [[ "$MILESTONE" == "major-version" ]]; then | |
| pnpm run bumpManifestVer major $VERSION | |
| elif [[ "$MILESTONE" == "minor-version" ]]; then | |
| pnpm run bumpManifestVer minor $VERSION | |
| else | |
| pnpm run bumpManifestVer patch $VERSION | |
| fi | |
| pnpm prettier --write manifest.json | |
| - name: Update the Manifest in git | |
| run: | | |
| git add manifest.json | |
| git commit -m "Updated Manifest" | |
| git push origin master | |
| - name: Package app zip | |
| working-directory: dist | |
| run: | | |
| cp ../manifest.json . | |
| zip -rq ../app.zip * | |
| mv ../app.zip . | |
| - name: Read manifest | |
| id: read_manifest | |
| run: | | |
| content=`cat ./manifest.json | tr -d '\n'` | |
| echo "manifest=$content" >> $GITHUB_OUTPUT | |
| - name: Create safe package filename | |
| id: create_package_filename | |
| run: | | |
| packageFilename=`echo "${{ fromJson(steps.read_manifest.outputs.manifest).name }}" | iconv -t ascii//TRANSLIT | sed -r s/[~\^]+//g | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\|-+$//g | tr A-Z a-z` | |
| echo "packageFilename=$packageFilename" >> $GITHUB_OUTPUT | |
| - name: Rename package | |
| id: rename_app_package | |
| run: | | |
| (cd ./dist && mv app.zip ${{ steps.create_package_filename.outputs.packageFilename }}.zip) | |
| - name: Create release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ fromJson(steps.read_manifest.outputs.manifest).version }} | |
| draft: false | |
| prerelease: false | |
| files: | | |
| ./dist/${{ steps.create_package_filename.outputs.packageFilename }}.zip | |
| ./dist/manifest.json | |
| release: | |
| uses: DeskproApps/app-template-vite/.github/workflows/subworkflow-release.yml@master | |
| secrets: inherit | |
| needs: [deskpro_app_test_and_build] |