-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (63 loc) · 2.55 KB
/
publish.yml
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Deploy Website
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: "publish"
cancel-in-progress: true
env:
WEBSITE_SOURCES_DIR: sources
WEBSITE_CONTENT_DIR: result
WEBSITE_CONTENT_REPO: eclipse-sirius/sirius-website
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout templates
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ env.WEBSITE_SOURCES_DIR }}
- name: Checkout content website
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: ${{ env.WEBSITE_CONTENT_REPO }}
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ env.WEBSITE_CONTENT_DIR }}
- name: Setup Ruby
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.1
with:
ruby-version: '3.2.2'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
working-directory: ${{ env.WEBSITE_SOURCES_DIR }}
- name: Prune current content
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: git rm -rf *
- name: Build website
working-directory: ${{ env.WEBSITE_SOURCES_DIR }}
env:
JEKYLL_ENV: production
run: |
bundle exec jekyll build
mv _site/sirius/* ${{ github.workspace }}/${{ env.WEBSITE_CONTENT_DIR }}
- name: Check for content changes
id: git-check
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: |
git add -A
echo ::set-output name=modified::$(if git diff --cached --exit-code --quiet; then echo "false"; else echo "true"; fi)
- name: Push content changes
if: steps.git-check.outputs.modified == 'true'
working-directory: ${{ env.WEBSITE_CONTENT_DIR }}
run: |
git config user.name ${{ github.event.head_commit.author.name }}
git config user.email ${{ github.event.head_commit.author.email }}
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | xargs -L1 git config --unset-all
git remote set-url origin https://x-access-token:${{ secrets.GH_ACTION_TOKEN }}@github.com/${{ env.WEBSITE_CONTENT_REPO }}
git commit -am "${{ github.event.head_commit.message }}"
git push origin