-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (74 loc) · 2.26 KB
/
main.yaml
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
69
70
71
72
73
74
75
76
77
name: Main Workflow
on:
create:
tags:
- '*'
push:
branches-ignore:
- gh_pages
tags:
- '*'
pull_request:
workflow_dispatch:
jobs:
build:
name: Build CV
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@master
## Retrieve context to define variables
- name: 'Get tag value (if run triggered by a tag)'
if: startsWith(github.ref, 'refs/tags/')
id: tags
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Get branch name
if: startsWith(github.ref, 'refs/heads/')
id: branches
run: echo ::set-output name=branch::${GITHUB_REF#refs/heads/}
- name: 'Build'
run: make all
- name: Test
run: make test
- name: 'Upload dist/ as artefact'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
deploy:
runs-on: ubuntu-latest
needs:
- build
# Only run deploy when pushing code on a branch of the repository
if: github.event_name == 'push'
steps:
- name: 'Download dist/ Artefacts'
uses: actions/download-artifact@v4
with:
name: dist
path: ./dist
# Deploy
- name: 'Deploy Tag (if run triggered by a tag)'
if: startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
destination_dir: ${{ steps.tags.outputs.tag }}
keep_files: true
- name: 'Deploy Branch (if run triggered by a push to a branch)'
if: startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
destination_dir: ${{ steps.branches.outputs.branch }}
keep_files: true
- name: 'Deploy Principal Branch (if run triggered by a push to the principal branch)'
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
destination_dir: ./
keep_files: true