Skip to content

Commit 12a72c0

Browse files
committed
first
0 parents  commit 12a72c0

14 files changed

Lines changed: 621 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 'Docker Build Action'
2+
description: 'Builds a Docker image using a specified Dockerfile and context'
3+
4+
inputs:
5+
context:
6+
description: 'The Docker build context (path to the directory containing the Dockerfile)'
7+
required: true
8+
default: '.'
9+
dockerfile:
10+
description: 'The path to the Dockerfile (relative to the context)'
11+
required: true
12+
default: 'Dockerfile'
13+
buildArgVersionName:
14+
description: 'The name of the build argument'
15+
required: false
16+
buildArgVersionValue:
17+
description: 'The value of the build argument'
18+
required: false
19+
target:
20+
description: 'The build target'
21+
required: false
22+
tag:
23+
description: 'The tag to use for the image'
24+
required: true
25+
image-name:
26+
description: 'The name of the image to build'
27+
required: true
28+
push:
29+
description: 'Determines if the built image should be pushed'
30+
required: true
31+
default: 'no'
32+
container-registry:
33+
description: 'container registry address (example: ghcr.io)'
34+
required: false
35+
container-registry-username:
36+
description: 'container registry username'
37+
required: false
38+
container-registry-password:
39+
description: 'container registry password'
40+
required: false
41+
42+
runs:
43+
using: 'composite'
44+
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Login to GitHub Container Registry
50+
uses: docker/login-action@v3
51+
if: ${{ inputs.push == 'true' }}
52+
with:
53+
logout: false
54+
registry: ${{ inputs.container-registry }}
55+
username: ${{ inputs.container-registry-username }}
56+
password: ${{ inputs.container-registry-password }}
57+
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Extract metadata (tags, labels) for Docker image
65+
id: meta
66+
uses: docker/metadata-action@v5
67+
with:
68+
images: |
69+
${{ inputs.container-registry }}/${{ github.repository_owner }}/${{ inputs.image-name }}
70+
tags: |
71+
type=raw,enable={{is_default_branch}},value=${{ inputs.tag }},priority=300
72+
type=sha,enable=true,priority=200,prefix=,suffix=,format=short
73+
type=raw,enable=true,value=${{ inputs.target }},priority=100
74+
75+
- name: Build image and push (optional)
76+
uses: docker/build-push-action@v6
77+
with:
78+
platforms: linux/amd64,linux/arm64
79+
push: ${{ inputs.push == 'true' }}
80+
context: ${{ inputs.context }}
81+
file: ${{ inputs.dockerfile }}
82+
target: ${{ inputs.target }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}
85+
build-args: |
86+
${{ inputs.buildArgVersionName }}=${{ inputs.buildArgVersionValue }}

.github/workflows/go.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Go Blueprints CI and CD
2+
3+
on:
4+
push:
5+
paths:
6+
- 'go/**'
7+
8+
pull_request:
9+
paths:
10+
- 'go/**'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: code-runner
15+
BUILD_ARG_VERSION_NAME: GO_VERSION
16+
concurrency:
17+
group: ${{ github.ref }}
18+
cancel-in-progress: true
19+
20+
jobs:
21+
ci:
22+
runs-on: ubuntu-latest
23+
24+
defaults:
25+
run:
26+
working-directory: ./go
27+
28+
strategy:
29+
matrix:
30+
go_version: [1.23, 1.24]
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v4
35+
36+
- name: Build go:${{ matrix.go_version }} image
37+
uses: ./.github/actions/docker-build
38+
with:
39+
context: .
40+
dockerfile: Dockerfile
41+
image-name: ${{ env.IMAGE_NAME }}
42+
target: production
43+
push: false
44+
container-registry: ${{ env.REGISTRY }}
45+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
46+
build-arg-version-value: ${{ matrix.go_version }}
47+
48+
cd:
49+
runs-on: ubuntu-latest
50+
51+
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
52+
53+
defaults:
54+
run:
55+
working-directory: ./go
56+
57+
strategy:
58+
matrix:
59+
go_version: [1.23, 1.24]
60+
61+
permissions:
62+
packages: write
63+
contents: read
64+
65+
needs:
66+
- ci
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Build and push go:${{ matrix.go_version }} image
73+
uses: ./.github/actions/docker-build
74+
with:
75+
context: .
76+
dockerfile: Dockerfile
77+
image-name: ${{ env.IMAGE_NAME }}
78+
target: production
79+
tag: go-${{ matrix.go_version }}
80+
push: true
81+
container-registry: ${{ env.REGISTRY }}
82+
container-registry-username: ${{ github.actor }}
83+
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
84+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
85+
build-arg-version-value: ${{ matrix.go_version }}

.github/workflows/nodejs.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Go Blueprints CI and CD
2+
3+
on:
4+
push:
5+
paths:
6+
- 'nodejs/**'
7+
8+
pull_request:
9+
paths:
10+
- 'nodejs/**'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: code-runner
15+
BUILD_ARG_VERSION_NAME: NODEJS_VERSION
16+
17+
concurrency:
18+
group: ${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
ci:
23+
runs-on: ubuntu-latest
24+
25+
defaults:
26+
run:
27+
working-directory: ./nodejs
28+
29+
strategy:
30+
matrix:
31+
nodejs_version: [20.19, 22.14, 23.11]
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Build nodejs:${{ matrix.nodejs_version }} image
38+
uses: ./.github/actions/docker-build
39+
with:
40+
context: .
41+
dockerfile: Dockerfile
42+
image-name: ${{ env.IMAGE_NAME }}
43+
target: production
44+
push: false
45+
container-registry: ${{ env.REGISTRY }}
46+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
47+
build-arg-version-value: ${{ matrix.nodejs_version }}
48+
49+
cd:
50+
runs-on: ubuntu-latest
51+
52+
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
53+
54+
defaults:
55+
run:
56+
working-directory: ./nodejs
57+
58+
strategy:
59+
matrix:
60+
nodejs_version: [20.19, 22.14, 23.11]
61+
62+
permissions:
63+
packages: write
64+
contents: read
65+
66+
needs:
67+
- ci
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Build and push nodejs:${{ matrix.nodejs_version }} image
74+
uses: ./.github/actions/docker-build
75+
with:
76+
context: .
77+
dockerfile: Dockerfile
78+
image-name: ${{ env.IMAGE_NAME }}
79+
target: production
80+
tag: nodejs-${{ matrix.nodejs_version }}
81+
push: true
82+
container-registry: ${{ env.REGISTRY }}
83+
container-registry-username: ${{ github.actor }}
84+
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
85+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
86+
build-arg-version-value: ${{ matrix.nodejs_version }}

.github/workflows/php.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Go Blueprints CI and CD
2+
3+
on:
4+
push:
5+
paths:
6+
- 'php/**'
7+
8+
pull_request:
9+
paths:
10+
- 'php/**'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: code-runner
15+
BUILD_ARG_VERSION_NAME: PHP_VERSION
16+
17+
concurrency:
18+
group: ${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
ci:
23+
runs-on: ubuntu-latest
24+
25+
defaults:
26+
run:
27+
working-directory: ./php
28+
29+
strategy:
30+
matrix:
31+
php_version: [8.3, 8.4]
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Build php:${{ matrix.php_version }} image
38+
uses: ./.github/actions/docker-build
39+
with:
40+
context: .
41+
dockerfile: Dockerfile
42+
image-name: ${{ env.IMAGE_NAME }}
43+
target: production
44+
push: false
45+
container-registry: ${{ env.REGISTRY }}
46+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
47+
build-arg-version-value: ${{ matrix.php_version }}
48+
49+
cd:
50+
runs-on: ubuntu-latest
51+
52+
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
53+
54+
defaults:
55+
run:
56+
working-directory: ./php
57+
58+
strategy:
59+
matrix:
60+
php_version: [8.3, 8.4]
61+
62+
permissions:
63+
packages: write
64+
contents: read
65+
66+
needs:
67+
- ci
68+
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Build and push php:${{ matrix.php_version }} image
74+
uses: ./.github/actions/docker-build
75+
with:
76+
context: .
77+
dockerfile: Dockerfile
78+
image-name: ${{ env.IMAGE_NAME }}
79+
target: production
80+
tag: php-${{ matrix.php_version }}
81+
push: true
82+
container-registry: ${{ env.REGISTRY }}
83+
container-registry-username: ${{ github.actor }}
84+
container-registry-password: ${{ secrets.GITHUB_TOKEN }}
85+
build-arg-version-name: ${{ env.BUILD_ARG_VERSION_NAME }}
86+
build-arg-version-value: ${{ matrix.php_version }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.vscode
3+
.idea
4+
5+
/private
6+
/private.pub
7+
/tmp

go/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Accept Go version as build argument
2+
ARG GO_VERSION=1.24
3+
4+
FROM golang:${GO_VERSION}-alpine
5+
6+
RUN apk add --no-cache bash coreutils
7+
8+
WORKDIR /app
9+
10+
COPY run.sh /run.sh
11+
RUN chmod +x /run.sh
12+
13+
ENTRYPOINT ["/run.sh"]

0 commit comments

Comments
 (0)