This repository was archived by the owner on Apr 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (137 loc) · 4.61 KB
/
docker-compose-build.yml
File metadata and controls
144 lines (137 loc) · 4.61 KB
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
136
137
138
139
140
141
142
143
144
---
name: docker-compose-build
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- closed
jobs:
docker-compose-build:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
REPOSITORY: ${{github.repository}}
permissions:
contents: read
packages: write
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed' && github.repository == github.event.pull_request.head.repo.full_name)
steps:
- uses: actions/checkout@v3.5.2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
# jscpd:ignore-start
- run: cat .env.example >>"$GITHUB_ENV"
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: ${{ github.event_name == 'pull_request' }}
# jscpd:ignore-end
- name: Build and push (develop)
uses: docker/bake-action@v3.0.1
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,dev.docker-compose.yml
- name: Build and push (production)
uses: docker/bake-action@v3.0.1
env:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,production.docker-compose.yml
format-go:
runs-on: ubuntu-latest
needs: docker-compose-build
if: always() && (needs.docker-compose-build.result == 'success' || (github.event_name == 'pull_request' && github.event.action == 'closed'))
permissions:
contents: write
pull-requests: write
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- run: cat .env.example >> "$GITHUB_ENV"
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: github.event_name == 'pull_request'
- name: Get Go version
id: get_go_version
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/docker_compose_build/format_go/get_go_version.sh"
- name: Set up Go
uses: actions/setup-go@v4
if: github.event_name != 'pull_request' || github.event.action != 'closed'
with:
go-version: ${{steps.get_go_version.outputs.go_version}}
- name: Format files
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/docker_compose_build/format_go/format_files.sh"
- uses: dev-hato/actions-diff-pr-management@v1.1.3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-format
pr-title-prefix: formatが間違ってたので直してあげたよ!
update-dockle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: dev-hato/actions-update-dockle@v0.0.53
with:
github-token: ${{secrets.GITHUB_TOKEN}}
dockle:
runs-on: ubuntu-latest
needs:
- docker-compose-build
- update-dockle
strategy:
matrix:
docker_compose_file_name: [ "dev.docker-compose.yml", "production.docker-compose.yml" ]
env:
DOCKER_CONTENT_TRUST: 1
REPOSITORY: ${{github.repository}}
steps:
- uses: actions/checkout@v3.5.2
# jscpd:ignore-start
- run: cat .env.example >>"$GITHUB_ENV"
- run: echo "TAG_NAME=${HEAD_REF//\//-}" >> "$GITHUB_ENV"
env:
HEAD_REF: ${{github.head_ref}}
if: ${{ github.event_name == 'pull_request' }}
# jscpd:ignore-end
- env:
DOCKER_COMPOSE_FILE_NAME: ${{matrix.docker_compose_file_name}}
run: bash "${GITHUB_WORKSPACE}/scripts/docker_compose_build/dockle/run_dockle.sh"
docker-compose-build-complete:
runs-on: ubuntu-latest
needs:
- format-go
- dockle
steps:
- run: exit 0
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true