Skip to content

Dedup Release Workflows (#4) #7

Dedup Release Workflows (#4)

Dedup Release Workflows (#4) #7

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Last commit
on: [push]
jobs:
build:
runs-on: ubuntu-latest
outputs:
should-commit-status: ${{ contains(steps.can_commit.outputs.commit_result, 'nothing to commit') == false }}
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@master
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Build files with Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run webpack
- run: npm run babel
- name: Add file(s) for commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -f dist/person-entity-card-bundle.js
- name: Commit changes
id: can_commit
run: |-
commit_result=$(git commit -m "Add changes to dist" -a | tr -d '\n' || true)
echo "::set-output name=commit_result::$commit_result"
- name: Nothing to commit
if: contains(steps.can_commit.outputs.commit_result, 'nothing to commit')
run: echo "No changes found (for both main code and docs). Skipping push."
- name: Dump GitHub context
run: echo $JSON
env:
JSON: ${{ toJSON(github) }}
- name: Push changes to target branch
if: (contains(steps.can_commit.outputs.commit_result, 'nothing to commit') == false)
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
# this job will only run if steps.check.outputs.triggered == 'true'
# you just need to write the if once
tag:
runs-on: ubuntu-latest
needs: [build]
if: needs.build.outputs.should-commit-status == 'true'
steps:
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
append_to_pre_release_tag: ''
default_bump: false
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: New release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: 'dist/person-entity-card-bundle.js'
body: ${{ steps.tag_version.outputs.changelog }}
commit: 'main'
name: Release ${{ steps.tag_version.outputs.new_tag }}
owner: 'GuyKh'
repo: 'person-entity-card'
tag: ${{ steps.tag_version.outputs.new_tag }}
token: ${{ secrets.GITHUB_TOKEN }}