Merge pull request #677 from lukso-network/dependabot/npm_and_yarn/sa… #2441
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: ci | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
env: | |
CF_PROJECT_NAME: tech-docs | |
CF_BASE_URL: tech-docs-2ac | |
jobs: | |
checks: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.18.1' | |
cache: 'yarn' | |
- name: Install ⚙️ | |
run: yarn install --frozen-lockfile | |
- name: Prettier 🎨 | |
run: yarn run prettier | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: checks | |
steps: | |
- name: Checkout 🛎️ | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.18.1' | |
cache: 'yarn' | |
- name: Install ⚙️ | |
run: yarn install --frozen-lockfile | |
- name: Build 🛠 | |
run: yarn build | |
- name: Extract branch name | |
shell: bash | |
run: | | |
PR_NUMBER="${{ github.event.number }}" | |
if [ -n "$PR_NUMBER" ] | |
then | |
echo "branch_name=pr-${PR_NUMBER}" >> $GITHUB_OUTPUT | |
echo "url=https://pr-${PR_NUMBER}.${{ env.CF_BASE_URL }}.pages.dev" >> $GITHUB_OUTPUT | |
echo "branch=--branch pr-${PR_NUMBER}" >> $GITHUB_OUTPUT | |
else | |
echo "branch_name=" >> $GITHUB_OUTPUT | |
echo "branch=" >> $GITHUB_OUTPUT | |
fi | |
id: extract_branch | |
- name: Deploy | |
uses: cloudflare/[email protected] | |
with: | |
apiToken: ${{ secrets.CF_API_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
command: pages deploy --project-name "${CF_PROJECT_NAME}" build ${{ steps.extract_branch.outputs.branch }} | tee output.log | |
postCommands: | | |
sed < output.log -n 's#.*Take a peek over at \(.*\)$#specific_url=\1#p' >> $GITHUB_OUTPUT | |
id: deploy | |
- name: Create commit comment | |
uses: mshick/add-pr-comment@v2 | |
if: ${{ github.event.number != '' }} | |
with: | |
message: | | |
### Deployed with **Cloudflare Pages** :cloud: :rocket: :ok: | |
- **URL**: [${{ steps.extract_branch.outputs.url }}](${{ steps.extract_branch.outputs.url }}) | |
- **Specific**: [${{ steps.deploy.outputs.specific_url }}](${{ steps.deploy.outputs.specific_url }}) |