-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (90 loc) · 3.36 KB
/
docker-nginx.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
name: "docker-nginx runtime"
on:
workflow_dispatch:
push:
paths:
- "docker-nginx/**"
- ".github/**"
jobs:
test-docker-nginx:
uses: ./.github/workflows/test_with_docker_compose.yaml
needs:
- publish-container-image
with:
image: "docker-nginx"
publish-container-image:
runs-on: ubuntu-latest
needs:
- meta
steps:
- name: Log in to GitHub Container Registry as actor
uses: docker/login-action@v1
with:
registry: "${{ needs.meta.outputs.registry }}"
username: "${{ needs.meta.outputs.username }}"
password: "${{ github.token }}"
- uses: docker/setup-buildx-action@v1
- uses: docker/setup-qemu-action@v1
- uses: actions/checkout@v2
- name: Build Docker Image
uses: docker/build-push-action@v2
with:
outputs: "type=oci,dest=${{ needs.meta.outputs.archive }}"
platforms: "linux/amd64"
labels: "${{ needs.meta.outputs.labels }}"
context: "docker-nginx"
- name: Upload application's Docker Image as pipeline artifact
uses: actions/upload-artifact@v2
with:
path: "${{ needs.meta.outputs.archive }}"
name: "${{ needs.meta.outputs.archive }}"
- name: Push OCI archive (image) to registry for commit
uses: pr-mpt/actions-push-oci-archive-to-registry@v1
with:
archive: "${{ needs.meta.outputs.archive }}"
image: "${{ needs.meta.outputs.image_name }}"
tag: "${{ needs.meta.outputs.tags-commit }}"
- name: Tag image in registry with branch name
uses: shrink/actions-docker-registry-tag@v2
with:
registry: "${{ needs.meta.outputs.registry }}"
repository: "${{ needs.meta.outputs.image_repository }}"
target: "${{ needs.meta.outputs.tags-commit }}"
tags: "${{ needs.meta.outputs.tags-branch }}"
- name: Tag image as latest if build is on main branch
if: "${{ needs.meta.outputs.branch == 'main' }}"
uses: shrink/actions-docker-registry-tag@v2
with:
registry: "${{ needs.meta.outputs.registry }}"
repository: "${{ needs.meta.outputs.image_repository }}"
target: "${{ needs.meta.outputs.tags-commit }}"
tags: "latest"
meta:
runs-on: ubuntu-latest
outputs:
registry: "ghcr.io"
username: "${{ github.actor }}"
image_repository: "${{ github.repository }}-docker-nginx"
image_name: "ghcr.io/${{ github.repository }}-docker-nginx"
archive: "docker-nginx-${{ steps.commit.outputs.short }}.tar"
labels: "${{ steps.image.outputs.labels }}"
branch: "${{ steps.branch.outputs.sanitized-branch-name }}"
tags-commit: "${{ steps.commit.outputs.short }}"
tags-branch: "branches-${{ steps.branch.outputs.sanitized-branch-name }}"
steps:
- name: Get commit hash
id: commit
uses: pr-mpt/actions-commit-hash@v1
with:
prefix: "sha-"
- name: Generate branch Docker Image attributes
id: image
uses: docker/metadata-action@v3
with:
images: "ghcr.io/${{ github.repository }}-docker-nginx"
- id: branches
uses: tj-actions/branch-names@v5
- id: branch
uses: yeouchien/sanitize-branch-name-action@v1
with:
branch-name: "${{ steps.branches.outputs.current_branch }}"