-
Notifications
You must be signed in to change notification settings - Fork 3
109 lines (95 loc) · 4.65 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
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
name: Publish
on:
push:
branches: [main]
tags: ["*"]
pull_request:
branches: [main]
pull_request_target:
branches: [main]
jobs:
variables:
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.variables.outputs.ref }}
sha: ${{ steps.variables.outputs.sha }}
sha8: ${{ steps.variables.outputs.sha8 }}
date: ${{ steps.variables.outputs.date }}
version: ${{ steps.variables.outputs.version }}
docker_image_name: ${{ steps.variables.outputs.docker_image_name }}
docker_image_tag: ${{ steps.variables.outputs.docker_image_tag }}
docker_image_fqn: ${{ steps.variables.outputs.docker_image_fqn }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: "5.x.x"
- id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2
- name: Generate variables
id: variables
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.fullSemVer }}
docker-publish:
runs-on: ubuntu-latest
needs: variables
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Publish unstable Docker image to GitHub Package Registry
if: startsWith(github.ref, 'refs/tags/') != true
uses: whoan/docker-build-with-cache-action@v8.0.0
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: docker.pkg.github.com
image_name: jekyll-plantuml
image_tag: ${{ needs.variables.outputs.docker_image_tag }}
dockerfile: .docker/Dockerfile
push_image_and_stages: ./.github/scripts/docker_run_test.sh build --image ${{ needs.variables.outputs.docker_image_fqn }} --image-tag ${{ needs.variables.outputs.docker_image_tag }} --repository ${{ github.repository }} --dir ${{ github.workspace }}/tests/minimal --token ${{ secrets.GITHUB_TOKEN }} --verbose --no-pull
pull_image_and_stages: false
build_extra_args: --build-arg TAG="${{ needs.variables.outputs.docker_image_tag }}" --build-arg SHA="${{ needs.variables.outputs.sha }}" --build-arg DATE="${{ needs.variables.outputs.date }}" --build-arg VERSION="${{ needs.variables.outputs.version }}"
- name: Publish stable Docker image to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
uses: whoan/docker-build-with-cache-action@v8.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
image_name: swedbankpay/jekyll-plantuml
image_tag: ${{ needs.variables.outputs.docker_image_tag }}
dockerfile: .docker/Dockerfile
push_image_and_stages: ./.github/scripts/docker_run_test.sh build --image ${{ needs.variables.outputs.docker_image_fqn }} --image-tag ${{ needs.variables.outputs.docker_image_tag }} --repository ${{ github.repository }} --dir ${{ github.workspace }}/tests/minimal --token ${{ secrets.GITHUB_TOKEN }} --verbose --no-pull
pull_image_and_stages: false
build_extra_args: --build-arg TAG="${{ needs.variables.outputs.docker_image_tag }}" --build-arg SHA="${{ needs.variables.outputs.sha }}" --build-arg DATE="${{ needs.variables.outputs.date }}" --build-arg VERSION="${{ needs.variables.outputs.version }}"
docker-verify:
runs-on: ubuntu-latest
needs: [docker-publish, variables]
steps:
- uses: actions/checkout@v4
- name: Download and Run Image
run: |
./.github/scripts/docker_run_test.sh build \
--image ${{ needs.variables.outputs.docker_image_fqn }} \
--repository ${{ github.repository }} \
--dir ${{ github.workspace }}/tests/minimal \
--token ${{ secrets.GITHUB_TOKEN }} \
--image-tag ${{ needs.variables.outputs.docker_image_tag }} \
--verbose
- name: Deploy to GitHub Pages
run: |
./.github/scripts/deploy.sh \
--repository ${{ github.repository }} \
--ref ${{ github.ref }} \
--token ${{ secrets.GITHUB_TOKEN }} \
--image ${{ needs.variables.outputs.docker_image_fqn }} \
--verbose