Skip to content

Commit 6da53bc

Browse files
authored
Merge pull request #185 from ish-hcc/main
Add container CD files
2 parents a70c1f2 + 2cf17bb commit 6da53bc

6 files changed

Lines changed: 393 additions & 15 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# This workflow performs continuous delivery (CD).
2+
# This workflow will build a container image and publish it to container registries.
3+
name: Continuous Delivery (CD) for mc-observability-grafana
4+
5+
# When it's time to do a release,
6+
# do a full cross-platform build for all supported architectures and
7+
# push all of them to Docker Hub and GitHub Container Registry (GHCR).
8+
9+
on:
10+
# "Build and publish" on merged
11+
# Actually, there's no "merged" event.
12+
# A "push" event is occurred after the pull request "close" event with "merged" true condition.
13+
# The "push" event could replace "merged" event.
14+
push:
15+
branches:
16+
- main
17+
tags:
18+
- "v*.*.*"
19+
paths-ignore:
20+
- ".github/**"
21+
- "**.md"
22+
- "LICENSE"
23+
- ".gitignore"
24+
- "go/**"
25+
workflow_dispatch:
26+
27+
env:
28+
DOCKER_REGISTRY_NAME: cloudbaristaorg
29+
GHCR_REGISTRY_NAME: ${{ github.repository_owner }}
30+
IMAGE_NAME: mc-observability-grafana
31+
32+
jobs:
33+
# The job key is "publish-container-image"
34+
publish-container-image:
35+
# Job name is "Publish a container image"
36+
name: Publish a container image
37+
38+
# if: github.repository_owner == 'cloud-barista'
39+
40+
# This job runs on Ubuntu-latest (Ubuntu 20.04 LTS checked on 2022-09-06)
41+
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
42+
runs-on: ubuntu-22.04
43+
44+
steps:
45+
- name: Remove unused data
46+
run: docker system prune -a -f
47+
48+
- name: Checkout source code
49+
uses: actions/checkout@v4
50+
51+
# About billing for GitHub Packages
52+
# https://docs.github.com/en/billing/managing-billing-for-github-packages/about-billing-for-github-packages
53+
- name: Extract metadata from Git reference and GitHub events
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
# image name for Docker Hub
59+
${{env.DOCKER_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
60+
# image name for GitHub Container Registry (GHCR)
61+
ghcr.io/${{env.GHCR_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
62+
tags: |
63+
# See `tags` input: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
64+
## Tags for a push tag event
65+
# minimal (e.g., 1.2.3)
66+
type=semver,enable=true,pattern={{version}}
67+
# type=semver,pattern={{major}}.{{minor}}
68+
## Tags for a push branch event
69+
# Tags to reflect the last commit of the active branch
70+
type=edge,enable=true,branch=main
71+
## Other types (currently the followings may be out of scope in this project)
72+
## Tags for a push branch event
73+
# minimal (short sha)
74+
# type=sha,enable=true,format=short
75+
## Tags for a push or pull_request event
76+
type=ref,event=branch
77+
# type=ref,event=tag
78+
# type=ref,event=pr
79+
## Tags for a schedule event - handlebars with timezone (e.g. 20200110-093000)
80+
# type=schedule,enable=true,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v3
84+
with:
85+
platforms: all
86+
87+
- name: Set up Docker Buildx
88+
id: buildx
89+
uses: docker/setup-buildx-action@v3
90+
91+
- name: Cache Docker layers
92+
uses: actions/cache@v4
93+
with:
94+
path: /tmp/.buildx-cache
95+
key: ${{ runner.os }}-buildx-${{ github.sha }}
96+
restore-keys: |
97+
${{ runner.os }}-buildx-
98+
99+
- name: Login to Docker Hub
100+
uses: docker/login-action@v3
101+
with:
102+
username: ${{ secrets.DOCKER_USERNAME }}
103+
password: ${{ secrets.DOCKER_PASSWORD }}
104+
105+
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT`
106+
- name: Login to GitHub Container Registry
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ghcr.io
110+
username: ${{ github.repository_owner }}
111+
password: ${{ secrets.CR_PAT }}
112+
113+
- name: Build
114+
run: cd java-module && docker build . --file Dockerfile.grafana --tag $IMAGE_NAME
115+
116+
- name: Publish image
117+
id: docker_build_1
118+
uses: docker/build-push-action@v6
119+
with:
120+
builder: ${{ steps.buildx.outputs.name }}
121+
context: ./java-module
122+
file: ./java-module/Dockerfile.grafana
123+
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6
124+
push: ${{ github.event_name != 'pull_request' }}
125+
tags: ${{ steps.meta.outputs.tags }}
126+
cache-from: type=local,src=/tmp/.buildx-cache
127+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
128+
129+
- name: Image digest
130+
run: echo ${{ steps.docker_build.outputs.digest }}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# This workflow performs continuous delivery (CD).
2+
# This workflow will build a container image and publish it to container registries.
3+
name: Continuous Delivery (CD) for mc-observability-minio
4+
5+
# When it's time to do a release,
6+
# do a full cross-platform build for all supported architectures and
7+
# push all of them to Docker Hub and GitHub Container Registry (GHCR).
8+
9+
on:
10+
# "Build and publish" on merged
11+
# Actually, there's no "merged" event.
12+
# A "push" event is occurred after the pull request "close" event with "merged" true condition.
13+
# The "push" event could replace "merged" event.
14+
push:
15+
branches:
16+
- main
17+
tags:
18+
- "v*.*.*"
19+
paths-ignore:
20+
- ".github/**"
21+
- "**.md"
22+
- "LICENSE"
23+
- ".gitignore"
24+
- "go/**"
25+
workflow_dispatch:
26+
27+
env:
28+
DOCKER_REGISTRY_NAME: cloudbaristaorg
29+
GHCR_REGISTRY_NAME: ${{ github.repository_owner }}
30+
IMAGE_NAME: mc-observability-minio
31+
32+
jobs:
33+
# The job key is "publish-container-image"
34+
publish-container-image:
35+
# Job name is "Publish a container image"
36+
name: Publish a container image
37+
38+
# if: github.repository_owner == 'cloud-barista'
39+
40+
# This job runs on Ubuntu-latest (Ubuntu 20.04 LTS checked on 2022-09-06)
41+
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
42+
runs-on: ubuntu-22.04
43+
44+
steps:
45+
- name: Remove unused data
46+
run: docker system prune -a -f
47+
48+
- name: Checkout source code
49+
uses: actions/checkout@v4
50+
51+
# About billing for GitHub Packages
52+
# https://docs.github.com/en/billing/managing-billing-for-github-packages/about-billing-for-github-packages
53+
- name: Extract metadata from Git reference and GitHub events
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
# image name for Docker Hub
59+
${{env.DOCKER_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
60+
# image name for GitHub Container Registry (GHCR)
61+
ghcr.io/${{env.GHCR_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
62+
tags: |
63+
# See `tags` input: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
64+
## Tags for a push tag event
65+
# minimal (e.g., 1.2.3)
66+
type=semver,enable=true,pattern={{version}}
67+
# type=semver,pattern={{major}}.{{minor}}
68+
## Tags for a push branch event
69+
# Tags to reflect the last commit of the active branch
70+
type=edge,enable=true,branch=main
71+
## Other types (currently the followings may be out of scope in this project)
72+
## Tags for a push branch event
73+
# minimal (short sha)
74+
# type=sha,enable=true,format=short
75+
## Tags for a push or pull_request event
76+
type=ref,event=branch
77+
# type=ref,event=tag
78+
# type=ref,event=pr
79+
## Tags for a schedule event - handlebars with timezone (e.g. 20200110-093000)
80+
# type=schedule,enable=true,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v3
84+
with:
85+
platforms: all
86+
87+
- name: Set up Docker Buildx
88+
id: buildx
89+
uses: docker/setup-buildx-action@v3
90+
91+
- name: Cache Docker layers
92+
uses: actions/cache@v4
93+
with:
94+
path: /tmp/.buildx-cache
95+
key: ${{ runner.os }}-buildx-${{ github.sha }}
96+
restore-keys: |
97+
${{ runner.os }}-buildx-
98+
99+
- name: Login to Docker Hub
100+
uses: docker/login-action@v3
101+
with:
102+
username: ${{ secrets.DOCKER_USERNAME }}
103+
password: ${{ secrets.DOCKER_PASSWORD }}
104+
105+
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT`
106+
- name: Login to GitHub Container Registry
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ghcr.io
110+
username: ${{ github.repository_owner }}
111+
password: ${{ secrets.CR_PAT }}
112+
113+
- name: Build
114+
run: cd java-module && docker build . --file Dockerfile.minio --tag $IMAGE_NAME
115+
116+
- name: Publish image
117+
id: docker_build_1
118+
uses: docker/build-push-action@v6
119+
with:
120+
builder: ${{ steps.buildx.outputs.name }}
121+
context: ./java-module
122+
file: ./java-module/Dockerfile.minio
123+
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6
124+
push: ${{ github.event_name != 'pull_request' }}
125+
tags: ${{ steps.meta.outputs.tags }}
126+
cache-from: type=local,src=/tmp/.buildx-cache
127+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
128+
129+
- name: Image digest
130+
run: echo ${{ steps.docker_build.outputs.digest }}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# This workflow performs continuous delivery (CD).
2+
# This workflow will build a container image and publish it to container registries.
3+
name: Continuous Delivery (CD) for mc-observability-infra
4+
5+
# When it's time to do a release,
6+
# do a full cross-platform build for all supported architectures and
7+
# push all of them to Docker Hub and GitHub Container Registry (GHCR).
8+
9+
on:
10+
# "Build and publish" on merged
11+
# Actually, there's no "merged" event.
12+
# A "push" event is occurred after the pull request "close" event with "merged" true condition.
13+
# The "push" event could replace "merged" event.
14+
push:
15+
branches:
16+
- main
17+
tags:
18+
- "v*.*.*"
19+
paths-ignore:
20+
- ".github/**"
21+
- "**.md"
22+
- "LICENSE"
23+
- ".gitignore"
24+
- "go/**"
25+
workflow_dispatch:
26+
27+
env:
28+
DOCKER_REGISTRY_NAME: cloudbaristaorg
29+
GHCR_REGISTRY_NAME: ${{ github.repository_owner }}
30+
IMAGE_NAME: mc-observability-infra
31+
32+
jobs:
33+
# The job key is "publish-container-image"
34+
publish-container-image:
35+
# Job name is "Publish a container image"
36+
name: Publish a container image
37+
38+
# if: github.repository_owner == 'cloud-barista'
39+
40+
# This job runs on Ubuntu-latest (Ubuntu 20.04 LTS checked on 2022-09-06)
41+
# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
42+
runs-on: ubuntu-22.04
43+
44+
steps:
45+
- name: Remove unused data
46+
run: docker system prune -a -f
47+
48+
- name: Checkout source code
49+
uses: actions/checkout@v4
50+
51+
# About billing for GitHub Packages
52+
# https://docs.github.com/en/billing/managing-billing-for-github-packages/about-billing-for-github-packages
53+
- name: Extract metadata from Git reference and GitHub events
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
# image name for Docker Hub
59+
${{env.DOCKER_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
60+
# image name for GitHub Container Registry (GHCR)
61+
ghcr.io/${{env.GHCR_REGISTRY_NAME}}/${{env.IMAGE_NAME}}
62+
tags: |
63+
# See `tags` input: https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
64+
## Tags for a push tag event
65+
# minimal (e.g., 1.2.3)
66+
type=semver,enable=true,pattern={{version}}
67+
# type=semver,pattern={{major}}.{{minor}}
68+
## Tags for a push branch event
69+
# Tags to reflect the last commit of the active branch
70+
type=edge,enable=true,branch=main
71+
## Other types (currently the followings may be out of scope in this project)
72+
## Tags for a push branch event
73+
# minimal (short sha)
74+
# type=sha,enable=true,format=short
75+
## Tags for a push or pull_request event
76+
type=ref,event=branch
77+
# type=ref,event=tag
78+
# type=ref,event=pr
79+
## Tags for a schedule event - handlebars with timezone (e.g. 20200110-093000)
80+
# type=schedule,enable=true,pattern={{date 'YYYYMMDD-hhmmss' tz='Asia/Tokyo'}}
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v3
84+
with:
85+
platforms: all
86+
87+
- name: Set up Docker Buildx
88+
id: buildx
89+
uses: docker/setup-buildx-action@v3
90+
91+
- name: Cache Docker layers
92+
uses: actions/cache@v4
93+
with:
94+
path: /tmp/.buildx-cache
95+
key: ${{ runner.os }}-buildx-${{ github.sha }}
96+
restore-keys: |
97+
${{ runner.os }}-buildx-
98+
99+
- name: Login to Docker Hub
100+
uses: docker/login-action@v3
101+
with:
102+
username: ${{ secrets.DOCKER_USERNAME }}
103+
password: ${{ secrets.DOCKER_PASSWORD }}
104+
105+
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT`
106+
- name: Login to GitHub Container Registry
107+
uses: docker/login-action@v3
108+
with:
109+
registry: ghcr.io
110+
username: ${{ github.repository_owner }}
111+
password: ${{ secrets.CR_PAT }}
112+
113+
- name: Build
114+
run: cd java-module && docker build . --file Dockerfile.semaphore --tag $IMAGE_NAME
115+
116+
- name: Publish image
117+
id: docker_build_1
118+
uses: docker/build-push-action@v6
119+
with:
120+
builder: ${{ steps.buildx.outputs.name }}
121+
context: ./java-module
122+
file: ./java-module/Dockerfile.semaphore
123+
platforms: linux/amd64 # linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x,linux/arm/v6
124+
push: ${{ github.event_name != 'pull_request' }}
125+
tags: ${{ steps.meta.outputs.tags }}
126+
cache-from: type=local,src=/tmp/.buildx-cache
127+
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
128+
129+
- name: Image digest
130+
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)