-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (110 loc) · 3.48 KB
/
main.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
on:
pull_request:
push:
branches: main
permissions:
contents: write
packages: write
jobs:
build-docker:
runs-on: ubuntu-latest
name: Build Docker Image
outputs:
tag: ${{ steps.select_image.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Select Docker Image
id: select_image
shell: bash
run: |
ref=${{ github.ref_name }}
status=$(git diff --exit-code origin/main Dockerfile > /dev/null && echo "unchanged" || echo "changed")
if [[ "$ref" = "main" ]]; then
echo "build_image=true" >> "$GITHUB_OUTPUT";
echo "tag=latest" >> "$GITHUB_OUTPUT";
else
if [[ "$status" = "changed" ]]; then
echo "tag=$GITHUB_SHA" >> "$GITHUB_OUTPUT";
echo "build_image=true" >> "$GITHUB_OUTPUT";
else
echo "tag=latest" >> "$GITHUB_OUTPUT";
echo "build_image=false" >> "$GITHUB_OUTPUT";
fi;
fi;
- name: Login to GitHub Container Registry
if: steps.select_image.outputs.build_image == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
if: steps.select_image.outputs.build_image == 'true'
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/latex:${{ steps.select_image.outputs.tag }}
build-documents:
runs-on: ubuntu-latest
needs: build-docker
name: Build Documents
container:
image: ghcr.io/${{ github.repository_owner }}/latex:${{ needs.build-docker.outputs.tag }}
options: --user 1001
steps:
- uses: actions/checkout@v4
- name: Detect Version from Ref
shell: bash
id: detect_version
run: |
[[ $GITHUB_REF == refs/tags/v* ]] && VERSION="${GITHUB_REF#refs/tags/}" || VERSION="${GITHUB_SHA::8}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build with container
run: ./build.sh
working-directory: ./src
env:
VERSION: ${{ steps.detect_version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: output
path: |
./src/out/*.log
./src/out/*.pdf
release:
name: Release
needs: build-documents
# if: github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: output
pattern: "*.pdf"
- name: Get next version
uses: reecetech/[email protected]
id: version
with:
use_api: true
scheme: conventional_commits
increment: patch
- uses: softprops/action-gh-release@v2
with:
name: ${{ steps.version.outputs.v-version }}
tag_name: ${{ steps.version.outputs.v-version }}
generate_release_notes: true
# make_latest: true
make_latest: false
draft: true
fail_on_unmatched_files: true
files: |
secrist-resume.pdf
secrist-cv.pdf