-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (69 loc) · 2.02 KB
/
rails.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
name: Build Images
on:
push:
branches:
- main
jobs:
changes:
name: image list
runs-on: ubuntu-22.04
outputs:
changed: ${{ steps.filter.outputs.changed }}
matrix: ${{ steps.images.outputs.matrix }}
steps:
- id: checkout
uses: actions/checkout@v4
- id: filter
uses: dorny/paths-filter@v3
with:
base: ${{ github.ref }}
list-files: shell
filters: |
changed:
added|modified: 'rails/**'
- id: images
if: steps.filter.outputs.changed == 'true'
run: |
VERS=()
PATHS=(${{ steps.filter.outputs.changed_files }})
for p in "${PATHS[@]}" ; do
IFS='/' read -r -a parts <<< "$p"
IMAGES+=("${parts[1]}")
done
MATRIX=$(echo "${IMAGES[@]}" | tr ' ' '\n' | sort -u | jq -R | jq -sc '{context: .}')
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
docker-images:
runs-on: ubuntu-22.04
needs: changes
if: ${{ needs.changes.outputs.changed == 'true' }}
strategy:
matrix: ${{ fromJson(needs.changes.outputs.matrix) }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup qemu
uses: docker/setup-qemu-action@v3
- name: setup docker buildx
uses: docker/setup-buildx-action@v3
- name: login ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: base image
uses: docker/build-push-action@v5
with:
context: rails/${{ matrix.context }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/rails:${{ matrix.context }}
- name: Development Image
uses: docker/build-push-action@v5
with:
context: rails/${{ matrix.context }}/dev
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/rails:${{ matrix.context }}-dev