Merge branch 'develop' #155
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: Publish Npm Package And Deploy Github Pages | |
on: | |
push: | |
branches: [ develop, main, desktop ] | |
paths-ignore: | |
- 'README.md' | |
- '.github/*' | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.x, 14.x, 16.x] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- run: npm ci | |
- name: Test | |
env: | |
JEST_JUNIT_OUTPUT_DIR: test-results/unit | |
run: | | |
npm run test:lint -- --quiet --output-file test-results/eslint/results.xml --format junit | |
npm run test:unit -- --reporters="default" --reporters="jest-junit" --coverage --coverageReporters=text --coverageReporters=lcov --maxWorkers="2" | |
- name: Build | |
env: | |
NODE_ENV: production | |
GA_ID: ${{ secrets.GA_ID }} | |
NODE_OPTIONS: --max-old-space-size=4000 | |
run: npm run build | |
publish: | |
needs: check | |
runs-on: ubuntu-latest | |
env: | |
NPM_TAG: latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '14.x' | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- run: npm ci | |
# Don't push translations to TX. The push step will be run by the distro repository. | |
# - name: Push i18n | |
# if: ${{ github.ref == 'refs/heads/main' }} | |
# run: | | |
# export TX_TOKEN=${{ secrets.TX_TOKEN }} | |
# npm run i18n:src | |
# npm run i18n:push | |
- name: Update openblock-l10n | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: npm i --save openblock-l10n@latest | |
- name: Check for modified files | |
if: ${{ github.ref == 'refs/heads/main' }} | |
id: git-check | |
# Check if there are any files update, but ignore the case where only package-lock.json is updated. | |
run: | | |
echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ] && [ "$(git status --porcelain)" != " M package-lock.json" ]; then echo "true"; else echo "false"; fi) | |
- name: Update translations changes in GitHub repository | |
if: ${{ steps.git-check.outputs.modified == 'true' }} | |
id: git-push | |
run: | | |
git config --global user.name github-actions | |
git config --global user.email [email protected] | |
git add . | |
git commit -m '[skip ci] Update translations from transifex' | |
git remote add origin-translation https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git pull | |
git push --set-upstream origin-translation main | |
- name: Build | |
env: | |
NODE_ENV: production | |
GA_ID: ${{ secrets.GA_ID }} | |
NODE_OPTIONS: --max-old-space-size=4000 | |
run: npm run build | |
- name: Get package main version | |
if: ${{ github.ref == 'refs/heads/main' }} | |
id: package-version | |
uses: martinbeentjes/[email protected] | |
- name: Generate release version | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
echo "RELEASE_VERSION=${{ steps.package-version.outputs.current-version }}-prerelease.$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
- name: Set package version | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: npm --no-git-tag-version version $RELEASE_VERSION | |
- name: Tag release | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
git tag $RELEASE_VERSION | |
git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/$GITHUB_REPOSITORY $RELEASE_VERSION | |
- uses: JS-DevTools/npm-publish@v1 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Get branch name | |
id: get-branch-name | |
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/} | |
- name: Deploy | |
uses: peaceiris/[email protected] | |
with: | |
github_token: ${{ secrets.GH_TOKEN }} | |
publish_dir: ./build | |
destination_dir: ${{ steps.get-branch-name.outputs.short_ref }} |