summaryrefslogtreecommitdiffstats
path: root/.github/workflows/preview-pr.yaml
blob: f171f7125f89ec2155fe9e83aa1b8df39f6f832c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: preview-pr

on:
  pull_request_target:
    types: [opened, reopened, synchronize]
    
permissions:
  pull-requests: write 
    
jobs:
  authorize:
    environment:
      ${{ github.event_name == 'pull_request_target' &&
      github.event.pull_request.head.repo.full_name != github.repository &&
      'external' || 'internal' }}
    runs-on: ubuntu-latest
    steps:
      - run: "true"
      
  build:
    needs: authorize
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.0'
          bundler-cache: true
      - run: bundle exec jekyll build --baseurl ""
      - name: Publish to Cloudflare Pages
        id: preview-pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT }}
          projectName: hack-gpon-preview
          directory: _site
          branch: preview
      - uses: thollander/actions-comment-pull-request@v2
        with:
          message: |
            Preview of the website obtained from the PR: ${{ steps.preview-pages.outputs.url }}