|
2 | 2 | # Note: this file originates in template-action-docker # |
3 | 3 | # ---------------------------------------------------- # |
4 | 4 |
|
| 5 | +name: push |
| 6 | + |
5 | 7 | on: |
6 | 8 | - push |
7 | 9 | - workflow_dispatch |
8 | 10 |
|
9 | | -name: push |
10 | | - |
11 | | -concurrency: |
12 | | - group: ${{ github.ref }}-${{ github.workflow }} |
13 | | - |
14 | 11 | permissions: read-all |
15 | 12 |
|
16 | 13 | jobs: |
17 | | - metadata: |
18 | | - runs-on: ubuntu-latest |
19 | | - |
20 | | - outputs: |
21 | | - image-name: ${{ steps.image.outputs.name }} |
22 | | - repository_is_template: ${{ steps.metadata.outputs.repository_is_template }} |
23 | | - repository_default_branch: ${{ steps.metadata.outputs.repository_default_branch }} |
24 | | - |
25 | | - steps: |
26 | | - |
27 | | - |
28 | | - - id: metadata |
29 | | - uses: ahmadnassri/[email protected] |
30 | | - |
31 | | - - id: image |
32 | | - run: echo "name=$(basename "${GITHUB_REPOSITORY/docker-//}")" >> "$GITHUB_OUTPUT" |
33 | | - |
34 | | - commit-lint: |
35 | | - timeout-minutes: 5 |
36 | | - |
37 | | - runs-on: ubuntu-latest |
38 | | - |
39 | | - steps: |
40 | | - |
41 | | - |
42 | | - - uses: ahmadnassri/[email protected] |
43 | | - with: |
44 | | - config: .github/linters/.commit-lint.yml |
45 | | - |
46 | | - mega-linter: |
47 | | - timeout-minutes: 5 |
48 | | - |
49 | | - runs-on: ubuntu-latest |
50 | | - |
51 | | - steps: |
52 | | - |
53 | | - |
54 | | - - uses: oxsecurity/megalinter/flavors/[email protected] |
55 | | - env: |
56 | | - GITHUB_TOKEN: ${{ github.token }} |
57 | | - MEGALINTER_CONFIG: .github/linters/.mega-linter.yml |
58 | | - GITHUB_COMMENT_REPORTER: true |
59 | | - GITHUB_STATUS_REPORTER: true |
60 | | - |
61 | | - - uses: actions/upload-artifact@v3 |
62 | | - if: ${{ success() }} || ${{ failure() }} |
63 | | - with: |
64 | | - name: mega-linter-reports |
65 | | - path: | |
66 | | - megalinter-reports |
67 | | - mega-linter.log |
68 | | -
|
69 | | - release: |
70 | | - needs: |
71 | | - - metadata |
72 | | - - commit-lint |
73 | | - - mega-linter |
74 | | - |
75 | | - # only runs on main branch for non template repos |
76 | | - if: | |
77 | | - needs.metadata.outputs.repository_is_template == 'false' && |
78 | | - needs.metadata.outputs.repository_default_branch == github.ref_name |
79 | | -
|
80 | | - timeout-minutes: 5 |
81 | | - |
82 | | - runs-on: ubuntu-latest |
83 | | - |
84 | | - permissions: |
85 | | - contents: write |
86 | | - packages: write |
87 | | - |
88 | | - outputs: |
89 | | - published: ${{ steps.release.outputs.published }} |
90 | | - version: ${{ steps.release.outputs.release-version }} |
91 | | - version-major: ${{ steps.release.outputs.release-version-major }} |
92 | | - version-minor: ${{ steps.release.outputs.release-version-minor }} |
93 | | - |
94 | | - steps: |
95 | | - |
96 | | - with: |
97 | | - submodules: true |
98 | | - |
99 | | - - id: release |
100 | | - uses: ahmadnassri/[email protected] |
101 | | - with: |
102 | | - config: ${{ github.workspace }}/.semantic.json |
103 | | - env: |
104 | | - GITHUB_TOKEN: ${{ github.token }} |
105 | | - |
106 | | - publish-docker: |
107 | | - needs: |
108 | | - - release |
109 | | - - metadata |
110 | | - |
111 | | - timeout-minutes: 5 |
112 | | - |
113 | | - if: ${{ needs.release.outputs.published == 'true' }} |
114 | | - |
115 | | - name: publish to ghcr.io |
116 | | - |
117 | | - runs-on: ubuntu-latest |
118 | | - |
119 | | - permissions: |
120 | | - contents: read |
121 | | - packages: write |
122 | | - |
123 | | - steps: |
124 | | - |
125 | | - - uses: docker/setup-qemu-action@v2 |
126 | | - - uses: docker/setup-buildx-action@v2 |
127 | | - |
128 | | - # login to registry |
129 | | - - uses: docker/login-action@v2 |
130 | | - with: |
131 | | - registry: ghcr.io |
132 | | - username: ${{ github.repository_owner }} |
133 | | - password: ${{ github.token }} |
134 | | - |
135 | | - # publish |
136 | | - - uses: docker/build-push-action@v4 |
137 | | - with: |
138 | | - push: true |
139 | | - cache-from: type=gha |
140 | | - cache-to: type=gha,mode=max |
141 | | - platforms: linux/amd64,linux/arm64 |
142 | | - tags: | |
143 | | - ghcr.io/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:latest |
144 | | - ghcr.io/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.version-major }} |
145 | | - ghcr.io/${{ github.repository_owner }}/${{ needs.metadata.outputs.image-name }}:${{ needs.release.outputs.version }} |
146 | | - labels: | |
147 | | - org.opencontainers.image.title=${{ needs.metadata.outputs.image-name }} |
148 | | - org.opencontainers.image.url=${{ github.event.repository.html_url }} |
149 | | - org.opencontainers.image.version=${{ needs.release.outputs.version }} |
150 | | - org.opencontainers.image.source=${{ github.event.repository.html_url }} |
151 | | - org.opencontainers.image.revision=${{ github.sha }} |
152 | | -
|
153 | | - alias: |
154 | | - needs: release |
155 | | - |
156 | | - if: ${{ needs.release.outputs.published == 'true' }} |
157 | | - |
158 | | - runs-on: ubuntu-latest |
159 | | - |
| 14 | + main: |
| 15 | + uses: ahmadnassri/actions/.github/workflows/push-action-docker.yml@master |
| 16 | + secrets: inherit |
160 | 17 | permissions: |
161 | 18 | contents: write |
| 19 | + statuses: write |
162 | 20 | packages: write |
163 | | - |
164 | | - strategy: |
165 | | - matrix: |
166 | | - release: [ "v${{ needs.release.outputs.version }}" ] |
167 | | - alias: |
168 | | - - "v${{ needs.release.outputs.version-major }}" |
169 | | - - "v${{ needs.release.outputs.version-major }}.${{ needs.release.outputs.version-minor }}" |
170 | | - |
171 | | - steps: |
172 | | - - uses: actions/github-script@v6 |
173 | | - with: |
174 | | - script: | |
175 | | - const { data: { object: { sha } } } = await github.rest.git.getRef({ ...context.repo, ref: 'tags/${{ matrix.release }}' }) |
176 | | - await github.rest.git.deleteRef({ ...context.repo, ref: 'tags/${{ matrix.alias }}' }).catch(() => {}) |
177 | | - await github.rest.git.createRef({ ...context.repo, ref: 'refs/tags/${{ matrix.alias }}', sha }) |
178 | | -
|
179 | | - template-sync: |
180 | | - timeout-minutes: 5 |
181 | | - |
182 | | - needs: |
183 | | - - metadata |
184 | | - - commit-lint |
185 | | - - mega-linter |
186 | | - |
187 | | - # only runs on main branch for template repos |
188 | | - if: | |
189 | | - needs.metadata.outputs.repository_is_template == 'true' && |
190 | | - needs.metadata.outputs.repository_default_branch == github.ref_name |
191 | | -
|
192 | | - runs-on: ubuntu-latest |
193 | | - |
194 | | - steps: |
195 | | - |
196 | | - |
197 | | - - uses: ahmadnassri/[email protected] |
198 | | - with: |
199 | | - github-token: ${{ secrets.GH_TOKEN }} |
| 21 | + pull-requests: write |
0 commit comments