-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (108 loc) · 4.72 KB
/
pipeline.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: "pipeline"
on:
push:
branches: ['main']
pull_request:
branches: ['main']
jobs:
setup:
runs-on: ubuntu-latest
outputs:
# changed files output, might be relevant for other jobs
global_any_modified: ${{ steps.changed-files-yaml.outputs.global_any_modified }}
global_all_modified_files: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}
tests_all_modified_files: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}
tests_any_modified: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}
src_all_modified_files: ${{ steps.changed-files-yaml.outputs.src_all_modified_files }}
src_any_modified: ${{ steps.changed-files-yaml.outputs.src_any_modified }}
dockerfile_modified: ${{ steps.changed-files-yaml.outputs.dockerfile_any_modified }}
# trigger other jobs
trigger-build-and-test: ${{steps.set-triggers.outputs.trigger-build-and-test}}
trigger-release-docker: ${{steps.set-triggers.outputs.trigger-release-docker}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
submodules: true
- name: Get all relevant file changes
id: changed-files-yaml
uses: tj-actions/changed-files@v42
with:
files_yaml: |
global:
- '**'
tests:
- tests/**
src:
- src/**
dockerfile:
- Dockerfile
- name: set triggers
id: set-triggers
run: |
echo "trigger-build-and-test=${{ steps.changed-files-yaml.outputs.tests_any_modified == 'true' || steps.changed-files-yaml.outputs.src_any_modified == 'true' }}" >> $GITHUB_OUTPUT
echo "trigger-release-docker=${{ github.event_name == 'push' && (steps.changed-files-yaml.outputs.tests_any_modified == 'true' || steps.changed-files-yaml.outputs.src_any_modified == 'true' || steps.changed-files-yaml.outputs.dockerfile_modified == 'true') }}" >> $GITHUB_OUTPUT
echo "$GITHUB_OUTPUT"
- name: list outputs
run: |
echo "global:"
echo "- any: ${{ steps.changed-files-yaml.outputs.global_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}"
echo "tests:"
echo "- any: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}"
echo "src:"
echo "- any: ${{ steps.changed-files-yaml.outputs.src_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.src_all_modified_files }}"
echo "dockerfile: ${{ steps.changed-files-yaml.outputs.dockerfile_modified }}"
echo "computed outputs:"
echo "trigger build-and-test: ${{steps.set-triggers.outputs.trigger-build-and-test}}"
echo "trigger docker release: ${{steps.set-triggers.outputs.trigger-release-docker}}"
- name: list triggered jobs
run: |
echo "this should trigger the following jobs:"
echo "build-and-test-projects: ${{steps.set-triggers.outputs.trigger-build-and-test}}"
echo "release-docker-image: ${{steps.set-triggers.outputs.trigger-release-docker}}"
build-and-test:
name: "Build and test"
needs: setup
# https://github.com/actions/runner/issues/1173
if: needs.setup.outputs.trigger-build-and-test == 'true'
uses: nfdi4plants/actions-workflows/.github/workflows/build-and-test-solution.yml@main
with:
solution: ./arc-export.sln
checkout-submodules: true
configuration: Release
release-docker-image:
name: "Release Docker image"
needs: [setup, build-and-test]
if: needs.setup.outputs.trigger-release-docker == 'true'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: nfdi4plants/arc-export
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}