-
Notifications
You must be signed in to change notification settings - Fork 9
105 lines (93 loc) · 2.98 KB
/
build-team-image.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
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
name: Build changed team image
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
find-team-changes:
runs-on: ubuntu-latest
outputs:
modifiedTeams: ${{ steps.filter.outputs.changes }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v3
- name: 📂 Detect changed team folder
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
brown_independents:
- 'Teams/brown_independents/**'
ginger_mariners:
- 'Teams/ginger_mariners/**'
green_twins:
- 'Teams/green_twins/**'
pink_hotspurs:
- 'Teams/pink_hotspurs/**'
purple_saints:
- 'Teams/purple_saints/**'
red_titans:
- 'Teams/red_titans/**'
white_dodgers:
- 'Teams/white_dodgers/**'
yellow_pirates:
- 'Teams/yellow_pirates/**'
build-team-image:
name: Build team docker image
if: ${{ needs.find-team-changes.outputs.modifiedTeams != '[]' }}
runs-on: ubuntu-latest
needs: find-team-changes
strategy:
fail-fast: false
matrix:
team: ${{ fromJSON(needs.find-team-changes.outputs.modifiedTeams) }}
steps:
- name: ↩️ Checkout
uses: actions/checkout@v2
- name: 🏗️ Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: ℹ️ Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/hacktoberfestmunich/hacktoberfest-2023
tags: type=raw,value=${{ matrix.team }}
- name: 🔑 ghcr Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 💿 Build Image
if: ${{ github.event_name != 'push' }}
uses: docker/build-push-action@v4
with:
context: "Teams/${{ matrix.team }}"
push: false
file: Teams/${{ matrix.team }}/Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: 🚀 Build and push Image
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v4
with:
context: "Teams/${{ matrix.team }}"
push: true
file: Teams/${{ matrix.team }}/Dockerfile
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cleanup-images:
name: Cleanup untagged images from ghcr
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: find-team-changes
steps:
- name: 🗑️ Cleanup old untagged images
uses: dylanratcliffe/[email protected]
with:
org: ${{ github.repository_owner }}
token: ${{ secrets.HACKTOBERFEST2023_PAT }}
package_name: 'hacktoberfest-2023'