feat: update GitHub Actions workflow to use personal access token for… #9
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 Release | |
on: | |
pull_request: | |
branches: [ "main" ] | |
types: ["closed"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.18.1' | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build | |
- name: Get version from package.json | |
id: get_version | |
run: echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV | |
- name: Fetch all tags | |
run: git fetch --tags | |
- name: Create tag | |
if: github.event.pull_request.merged == true | |
id: create_tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git tag v${{ env.VERSION }} | |
git push https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }} v${{ env.VERSION }} | |
- name: Publish release | |
if: github.event.pull_request.merged == true | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "Release v${{ env.VERSION }} - $(date +'%Y-%m-%d')" | |
files: | | |
dist/** |