-
-
Notifications
You must be signed in to change notification settings - Fork 42
135 lines (115 loc) · 3.29 KB
/
ci.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
128
129
130
131
132
133
134
135
# https://docs.github.com/actions
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
metadata:
name: Metadata
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version-step.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Extract current version
id: version-step
run: echo "version=$(grep -oP '^ARG YOURLS_VERSION=\"\K[^\"]+' images/yourls/Dockerfile.template)" >> $GITHUB_OUTPUT
files:
name: Files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate variants
run: ./images/yourls/bin/generate-variants.sh dist/
- name: Prepare scripts
run: |
mkdir ./images/yourls/dist/bin
cp ./images/yourls/bin/* ./images/yourls/dist/bin
rm ./images/yourls/dist/bin/generate-variants.sh
- name: Copy version
run: grep -oP '^ARG YOURLS_VERSION="\K[^"]+' ./images/yourls/Dockerfile.template > ./images/yourls/dist/yourls_version
- name: Save files
uses: actions/upload-artifact@v3
with:
name: context-files
path: ./images/yourls/dist
build:
name: Build
runs-on: ubuntu-latest
needs:
- metadata
- files
strategy:
matrix:
variant: [fpm-alpine, fpm, apache]
steps:
- name: Retrieve context files
uses: actions/download-artifact@v3
with:
name: context-files
- run: chmod +x ./*/container-entrypoint.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v4
with:
context: ${{ matrix.variant }}
tags: yourls-test:${{ needs.metadata.outputs.version }}-${{ matrix.variant }}
outputs: type=docker,dest=/tmp/container-image.tar
cache-from: type=gha,scope=${{ matrix.variant }}
cache-to: type=gha,scope=${{ matrix.variant }},mode=max
- name: Save image
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.variant }}-image
path: /tmp/container-image.tar
retention-days: 1
test:
name: Test
runs-on: ubuntu-latest
needs:
- metadata
- build
strategy:
matrix:
variant: [fpm-alpine, fpm, apache]
steps:
- uses: actions/checkout@v3
with:
repository: docker-library/official-images
- name: Retrieve image artifact
uses: actions/download-artifact@v3
with:
name: ${{ matrix.variant }}-image
- name: Load image
run: docker load --input container-image.tar
- name: Test
run: ./test/run.sh "${IMAGE}"
env:
IMAGE: yourls-test:${{ needs.metadata.outputs.version }}-${{ matrix.variant }}
analysis:
name: Analysis
uses: ./.github/workflows/analysis.yml
permissions:
actions: read
contents: read
security-events: write
needs:
- metadata
- build
release:
name: Release
if: github.ref == 'refs/heads/main'
needs:
- metadata
- build
- test
uses: ./.github/workflows/release.yml
permissions:
contents: write
packages: write
id-token: write
with:
version: ${{ needs.metadata.outputs.version }}