@@ -16,74 +16,52 @@ jobs:
1616 steps :
1717 - name : Set Deployment ID
1818 run : |
19- # Tag manual trigger with "manual-trigger"
20- # Tag PR trigger with PR number
19+ # Use PR number for PR trigger and commit SHA for manual trigger
2120 if [[ -z "${{ github.event.pull_request.number }}" ]]; then
22- echo "DEPLOYMENT_ID=manual- trigger" >> $GITHUB_ENV
21+ echo "DEPLOYMENT_ID=trigger-${GITHUB_SHA::7} " >> $GITHUB_ENV
2322 else
2423 echo "DEPLOYMENT_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
2524 fi
2625 echo "DEPLOYMENT_ID=${{ env.DEPLOYMENT_ID }}"
2726
2827 - uses : actions/checkout@v3
2928 with :
30- path : ./repo
3129 repository : ${{ github.event.pull_request.head.repo.full_name }}
3230 ref : ${{ github.head_ref }}
3331
34- - name : Set up Docker Buildx
35- uses : docker/setup-buildx-action@v1
36-
37- - name : Build and push
38- uses : docker/build-push-action@v3
39- with :
40- context : ./repo
41- file : ./repo/Dockerfile
42- push : false
43- load : true
44- tags : operating-systems-${{ env.DEPLOYMENT_ID }}:latest
45- cache-from : type=gha
46- cache-to : type=gha
47-
48- - name : GitHub-specific config
32+ - name : Build Jekyll site
4933 run : |
50- cd repo
34+ # GitHub-specific config
5135 echo "url: https://${{ github.repository_owner }}.github.io" >> _config.yaml
5236 echo "baseurl: /operating-systems/${{ env.DEPLOYMENT_ID }}" >> _config.yaml
5337
54- - name : Load Image
55- run : |
56- mkdir -p ${{ env.DEPLOYMENT_ID }}
57- docker image list
58- docker run -v $GITHUB_WORKSPACE/${{ env.DEPLOYMENT_ID }}:/usr/src/app/_site \
59- -v $GITHUB_WORKSPACE/repo:/usr/src/app operating-systems-$ {{ env.DEPLOYMENT_ID }}:latest \
60- bundle exec jekyll build
61-
38+ # Build Docker image for Jekyll
39+ docker build -t jekyll-site .
40+
41+ # Build Jekyll site
42+ docker run --rm \
43+ -v ${{ github.workspace }}:/usr/src/app/ \
44+ jekyll-site bundle exec jekyll build
45+
6246 # Popular action to deploy to GitHub Pages:
6347 # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
6448 - name : Deploy to GitHub Pages
6549 uses : peaceiris/actions-gh-pages@v3
6650 with :
6751 github_token : ${{ secrets.GITHUB_TOKEN }}
68- # Build output to publish to the `gh-pages-pr` branch:
69- publish_dir : ./${{ env.DEPLOYMENT_ID }}
52+ publish_dir : _site
7053 destination_dir : ${{ env.DEPLOYMENT_ID }}
71- # The following lines assign commit authorship to the official
72- # GH-Actions bot for deploys to `gh-pages` branch:
73- # https://github.com/actions/checkout/issues/13#issuecomment-724415212
74- # The GH actions bot is used by default if you didn't specify the two fields.
75- # You can swap them out with your own user credentials.
7654 publish_branch : gh-pages
7755 enable_jekyll : true
7856
7957 - name : Add Comment to PR
80- if : ${{ env.DEPLOYMENT_ID != 'manual- trigger' }}
58+ if : ${{ !startsWith( env.DEPLOYMENT_ID, ' trigger-') }}
8159 uses : thollander/actions-comment-pull-request@v2
8260 with :
8361 message : |
8462 Published at https://${{ github.repository_owner }}.github.io/operating-systems/${{ env.DEPLOYMENT_ID }}/
8563
8664 - name : Output Deployment URL
87- if : ${{ env.DEPLOYMENT_ID == 'manual- trigger' }}
65+ if : ${{ startsWith( env.DEPLOYMENT_ID, ' trigger-') }}
8866 run : |
8967 echo "The deployment is available at https://${{ github.repository_owner }}.github.io/operating-systems/${{ env.DEPLOYMENT_ID }}/"
0 commit comments