Skip to content

Merge branch 'bot-testversion' of https://github.com/tamo/coi-service… #9

Merge branch 'bot-testversion' of https://github.com/tamo/coi-service…

Merge branch 'bot-testversion' of https://github.com/tamo/coi-service… #9

Workflow file for this run

name: check version number and minify
on:
push:
paths:
- 'coi-serviceworker.js'
- 'package.json'
permissions:
contents: write
jobs:
ci:
name: ci
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup node
uses: actions/setup-node@v3
- name: git config
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: npm ci
if: ${{ !contains(toJSON(github.event.modified), 'package.json') }}
run: npm ci
- name: npm install
if: ${{ contains(toJSON(github.event.modified), 'package.json') }}
run: npm install
- name: git diff package-lock.json
id: lockdiff
run: echo "diff_files=$(git diff --name-only | xargs)" >> "${GITHUB_ENV}"
- name: push package-lock.json
if: ${{ env.diff_files == 'package-lock.json' }}
run: |
git add package-lock.json
git commit -m "update package-lock.json"
git push origin HEAD:${GITHUB_REF}
- name: get package_version
run: npx -c 'echo "package_version=$npm_package_version"' >> "${GITHUB_ENV}"
- name: check package_version
run: echo "${package_version}" | grep -x -E '[0-9]+\.[0-9]+\.[0-9]+'
- name: get js_version
run: sed -n -r -e '1s,^/\*! coi-serviceworker v([0-9]+\.[0-9]+\.[0-9]+) - .*$,js_version=\1,;1p' coi-serviceworker.js >> "${GITHUB_ENV}"
- name: check js_version
run: echo "${js_version}" | grep -x -E '[0-9]+\.[0-9]+\.[0-9]+'
- name: push coi-serviceworker.js
if: env.package_version != env.js_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sed -i -r -e '1s/ v[0-9]+\.[0-9]+\.[0-9]+ / v'"${package_version}"' /' coi-serviceworker.js
git add coi-serviceworker.js
git commit -m "sync version numbers"
git push origin HEAD:${GITHUB_REF}
- name: minify
run: npm run minify
- name: git diff coi-serviceworker.min.js
id: mindiff
run: echo "diff_files=$(git diff --name-only | xargs)" >> "${GITHUB_ENV}"
- name: push coi-serviceworker.min.js
if: ${{ env.diff_files == 'coi-serviceworker.min.js' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add coi-serviceworker.min.js
git commit -m "minify"
git push origin HEAD:${GITHUB_REF}
- name: git diff
run: git diff --exit-code