Skip to content

Commit

Permalink
Merge pull request #670 from lukso-network/fix/add-cloudflare
Browse files Browse the repository at this point in the history
fix: Add cloudflare
  • Loading branch information
richtera authored Oct 13, 2023
2 parents e9f5079 + ca2dddb commit b0788da
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
59 changes: 50 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,84 @@ name: ci

on:
pull_request:
branches: [main]
push:
branches: [main]

env:
CF_PROJECT_NAME: tech-docs
CF_BASE_URL: tech-docs-2ac

jobs:
checks:
if: github.event_name != 'push'
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

- name: Build 🛠
run: yarn build

build-and-deploy:
if: github.event_name != 'pull_request'
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: Deploy 🚀
uses: JamesIves/[email protected]
- 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:
branch: gh-pages # The branch the action should deploy to.
folder: build # The folder the action should deploy.
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 }})
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.18.1
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ npm run docs:contracts:sync
```

2. Commit and push generated changes

# Note

Added some whitelisting of github actions.

0 comments on commit b0788da

Please sign in to comment.