Skip to content

Commit 4513c48

Browse files
committed
Refactor preview deployment workflow to enhance directory structure and artifact upload process
1 parent f02456b commit 4513c48

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/preview-deploy.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ jobs:
2020
build-preview:
2121
runs-on: ubuntu-latest
2222
if: github.event.action != 'closed'
23+
environment:
24+
name: github-pages-preview
25+
url: https://devnomadic.github.io/preview/${{ steps.branch-info.outputs.branch-name }}/
26+
permissions:
27+
contents: read
28+
pages: write
29+
id-token: write
2330
steps:
2431
- name: Checkout
2532
uses: actions/checkout@v4
@@ -51,13 +58,21 @@ jobs:
5158
env:
5259
JEKYLL_ENV: production
5360

54-
- name: Deploy to GitHub Pages preview
55-
uses: peaceiris/actions-gh-pages@v3
61+
- name: Setup Pages for preview
62+
id: pages-preview
63+
uses: actions/configure-pages@v4
64+
65+
- name: Create preview directory structure
66+
run: |
67+
mkdir -p preview-site/preview/${{ steps.branch-info.outputs.branch-name }}
68+
cp -r _site/* preview-site/preview/${{ steps.branch-info.outputs.branch-name }}/
69+
70+
- name: Upload preview artifact
71+
uses: actions/upload-artifact@v4
5672
with:
57-
github_token: ${{ secrets.GITHUB_TOKEN }}
58-
publish_dir: ./_site
59-
destination_dir: preview/${{ steps.branch-info.outputs.branch-name }}
60-
keep_files: true
73+
name: preview-site-${{ steps.branch-info.outputs.branch-name }}
74+
path: preview-site/
75+
retention-days: 7
6176

6277
- name: Comment on PR with preview URL
6378
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)