-
Notifications
You must be signed in to change notification settings - Fork 361
75 lines (66 loc) · 1.91 KB
/
templated_test_publish_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
name: Update Docker Image Reference on PR
on:
pull_request:
paths:
- 'templated_tests/**'
push:
branches:
- main
paths:
- 'templated_tests/**'
jobs:
changed-files:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.changed-files.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
matrix: true
dir_names: true
files: |
templated_tests/**
files_ignore: |
templated_tests/README.md
build-and-push-image:
needs: changed-files
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
files: ${{fromJson(needs.changed-files.outputs.matrix)}}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Docker image name
id: image_name
run: |
image_name=$(echo ${{ matrix.files }} | sed 's/templated_tests\///')
echo "::set-output name=image_name::${{ secrets.DOCKERHUB_USERNAME }}/$image_name"
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.image_name.outputs.image_name }}
tags: |
type=raw,value={{sha}},event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image to DockerHub
uses: docker/build-push-action@v6
with:
context: ${{ matrix.files }}
push: true
tags: ${{ steps.meta.outputs.tags }}