Skip to content

Bump semver from 5.7.1 to 5.7.2 #50

Bump semver from 5.7.1 to 5.7.2

Bump semver from 5.7.1 to 5.7.2 #50

Workflow file for this run

name: Website PR deployment - Sync
on:
pull_request:
types:
- opened
- synchronize
jobs:
build:
timeout-minutes: 20
env:
APP_NAME: 'webuild website'
DEPLOY_PREVIEW_URL: ''
BRANCH_NAME: ''
BOT_NAME: 'github-actions[bot]'
BOT_TYPE: Bot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache
id: yarn-cache
run: 'echo "::set-output name=dir::$(yarn cache dir)"'
- uses: actions/cache@v1
with:
path: '${{ steps.yarn-cache.outputs.dir }}'
key: "${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}"
restore-keys: |
${{ runner.os }}-yarn-
- name: Get BRANCH_NAME
run: |
echo "BRANCH_NAME=$(echo $GITHUB_HEAD_REF | tr / -)" >> $GITHUB_ENV
- name: Install dependencies
run: |
yarn
- name: Netlify deployment
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_APP_ID }}
NETLIFY_AUTH_TOKEN: '${{ secrets.NETLIFY_AUTH_TOKEN }}'
run: >
yarn build
echo "DEPLOY_PREVIEW_URL=$(npx netlify-cli deploy --dir=public --message='Pull Request
$GITHUB_HEAD_REF'| grep "Website Draft URL" | grep -o -E 'https?://[^
]+' )" >> $GITHUB_ENV
- uses: actions/github-script@0.3.0
with:
github-token: '${{secrets.GITHUB_TOKEN}}'
script: >
const comments = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
const commitLink =
`https://github.com/webuild-community/webuild.community/commit/${context.sha}`
const regex = new RegExp('<!--\\s\\[${{ env.APP_NAME
}}-'+context.payload.pull_request.number+'\\]\\s-->\\n')
const commentsOfGithubBot = comments.data.filter(c => c.user.login
=== '${{ env.BOT_NAME }}' && c.user.type === '${{ env.BOT_TYPE }}'
&& regex.test(c.body))
if(commentsOfGithubBot.length === 0) {
const newComment = await github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '<!-- [${{ env.APP_NAME }}-' + `${context.payload.pull_request.number}` + '] -->\n' + 'Deploy preview for _${{ env.APP_NAME }}_ ready!<br/><br/>Built with commit ' + `${context.sha}<br/><br/>` + '${{ env.DEPLOY_PREVIEW_URL }}'
})
return JSON.stringify({commitLink, pullRequestLink: newComment.data.html_url})
} else {
const latestCommentId = commentsOfGithubBot.pop().id
const updatedComment = await github.issues.updateComment({
comment_id: latestCommentId,
owner: context.repo.owner,
repo: context.repo.repo,
body: '<!-- [${{ env.APP_NAME }}-' + `${context.payload.pull_request.number}` + '] -->\n' + 'Deploy preview for _${{ env.APP_NAME }}_ ready!<br/><br/>Built with commit ' + `${context.sha}<br/><br/>` + '${{ env.DEPLOY_PREVIEW_URL }}'
})
return JSON.stringify({commitLink, pullRequestLink: updatedComment.data.html_url})
}
id: githubComment