Skip to content

Merge pull request #858 from citation-file-format/release-2.3.1 #472

Merge pull request #858 from citation-file-format/release-2.3.1

Merge pull request #858 from citation-file-format/release-2.3.1 #472

Workflow file for this run

name: Preview
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
workflow_dispatch:
jobs:
preview:
if: github.repository == 'citation-file-format/cff-initializer-javascript'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Run npm clean-install
run: npm clean-install
- name: Run build on PR
run: |
if [[ ${{ github.event_name }} == "pull_request" ]]; then
export PUBLICPATH=PR${{ github.event.number }}
else
export PUBLICPATH=$GITHUB_REF_NAME
fi
echo "PUBLICPATH=$PUBLICPATH" >> $GITHUB_ENV
sed -i "s|publicPath: 'cff-initializer-javascript'|publicPath: '$PUBLICPATH'|" quasar.conf.js
npm run build
- name: Deploy to gh-preview
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-preview
destination_dir: "${{ env.PUBLICPATH }}"
publish_dir: ./dist
user_name: 'cffinit[bot]'
user_email: 'cffinit[bot]@users.noreply.github.com'
commit_message: ':robot: Create preview of ${{ env.PUBLICPATH }}'
pr_comment:
if: github.event_name == 'pull_request' && github.repository == 'citation-file-format/cff-initializer-javascript'
needs: preview
runs-on: ubuntu-latest
steps:
- name: 'Comment PR'
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
github.issues.createComment({ issue_number, owner, repo, body: 'Once the build has completed, you can preview your PR at this URL: https://cffinit.netlify.app/PR${{ github.event.number }}/' });