Skip to content

Commit 8204174

Browse files
committed
[GitHub] Create Release Action (#57)
1 parent 1cd5a08 commit 8204174

File tree

9 files changed

+433
-1
lines changed

9 files changed

+433
-1
lines changed

.github/workflows/_pullRequest.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Pull Request
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'actions/**/Dockerfile'
7+
- 'actions/**/main.go'
8+
- 'actions/**/go.mod'
9+
- 'actions/**/go.sum'
10+
- 'actions/**/action.yml'
11+
12+
jobs:
13+
FindActionDockerfiles:
14+
name: Find Action Dockerfiles
15+
runs-on: ubuntu-latest
16+
outputs:
17+
matrix: ${{ steps.find-dockerfiles.outputs.matrix }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Find Dockerfiles in actions
23+
id: find-dockerfiles
24+
run: |
25+
dockerfiles=$(find actions -name "Dockerfile" -type f -exec dirname {} \; | jq -R -s -c 'split("\n")[:-1]')
26+
echo "matrix={\"actionPath\":$dockerfiles}" >> $GITHUB_OUTPUT
27+
echo "Found action paths with Dockerfiles: $dockerfiles"
28+
29+
ValidateDockerBuilds:
30+
name: Validate Docker Build
31+
runs-on: ubuntu-latest
32+
needs: FindActionDockerfiles
33+
if: needs.FindActionDockerfiles.outputs.matrix != '{"actionPath":[]}'
34+
strategy:
35+
matrix: ${{ fromJson(needs.FindActionDockerfiles.outputs.matrix) }}
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Build Docker Image (No Push)
41+
run: |
42+
cd "${{ matrix.actionPath }}"
43+
action_name=$(basename "${{ matrix.actionPath }}" | tr '[:upper:]' '[:lower:]')
44+
echo "Building Docker image for action: $action_name"
45+
docker build -t test-$action_name:pr-${{ github.event.pull_request.number }} .
46+
echo "✅ Docker build successful for $action_name"

.github/workflows/_release.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@ on:
1111
permissions:
1212
pull-requests: write
1313
contents: write
14+
packages: write
1415

1516
jobs:
17+
BuildCreateReleaseImage:
18+
name: Build createRelease Action Image
19+
uses: ./.github/workflows/github_createAndReleaseActionDockerImage.yml
20+
with:
21+
actionPath: 'actions/github/createRelease'
22+
imageName: 'gh-action-create-github-release'
23+
secrets:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
1626
CreateRelease:
1727
name: Create Release
1828
uses: ./.github/workflows/github_createRelease.yml
@@ -37,4 +47,4 @@ jobs:
3747
git tag -d v$major_version
3848
git push origin --delete v$major_version
3949
git tag v$major_version ${{github.ref}}
40-
git push origin v$major_version
50+
git push origin v$major_version
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Create and Release Action Docker Image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
actionPath:
7+
description: 'Path to the action directory containing Dockerfile'
8+
required: true
9+
type: string
10+
imageName:
11+
description: 'Name of the Docker image (without registry prefix)'
12+
required: true
13+
type: string
14+
registryPrefix:
15+
description: 'Container registry prefix'
16+
required: false
17+
type: string
18+
default: 'ghcr.io/encoredigitalgroup'
19+
secrets:
20+
token:
21+
description: 'GitHub token for authentication'
22+
required: true
23+
24+
jobs:
25+
BuildAndPushDockerImage:
26+
name: Build and Push Docker Image
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Log in to GitHub Container Registry
33+
run: echo ${{ secrets.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
34+
35+
- name: Build and Push Docker Image
36+
run: |
37+
cd ${{ inputs.actionPath }}
38+
docker build -t ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest .
39+
docker tag ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:${{ github.ref_name }}
40+
docker push ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:latest
41+
docker push ${{ inputs.registryPrefix }}/${{ inputs.imageName }}:${{ github.ref_name }}
42+
43+
- name: Output Image Details
44+
run: |
45+
echo "Docker image built and pushed successfully:"
46+
echo "Image: ${{ inputs.registryPrefix }}/${{ inputs.imageName }}"
47+
echo "Tags: latest, ${{ github.ref_name }}"

.github/workflows/github_createRelease.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
name: CreateRelease
2828
runs-on: ubuntu-latest
2929
steps:
30+
- name: Deprecation Warning
31+
run: |
32+
echo "::warning::This workflow (github_createRelease.yml) is deprecated. Please use the actions/github/createRelease action instead."
33+
echo "::warning::Migration guide: Replace 'uses: ./.github/workflows/github_createRelease.yml' with 'uses: ./actions/github/createRelease'"
34+
echo "::warning::The new action provides better performance, more features, and includes Dependabot filtering options."
35+
3036
- name: Create Release
3137
id: createRelease
3238
uses: ncipollo/release-action@v1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM golang:1.24-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
# Copy go mod and sum files
6+
COPY go.mod go.sum ./
7+
8+
# Download dependencies
9+
RUN go mod download
10+
11+
# Copy source code
12+
COPY main.go ./
13+
14+
# Build the binary
15+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
16+
17+
# Final stage - minimal image
18+
FROM alpine:latest
19+
20+
# Install ca-certificates for HTTPS requests
21+
RUN apk --no-cache add ca-certificates
22+
23+
WORKDIR /root/
24+
25+
# Copy the binary from builder stage
26+
COPY --from=builder /app/main .
27+
28+
# Run the binary
29+
ENTRYPOINT ["./main"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Create Release'
2+
description: 'Creates a GitHub Release'
3+
inputs:
4+
token:
5+
description: 'GitHub token'
6+
required: true
7+
preRelease:
8+
description: 'Pre-release'
9+
required: false
10+
default: 'false'
11+
generateReleaseNotes:
12+
description: 'Generate release notes'
13+
required: false
14+
default: 'true'
15+
isDraft:
16+
description: 'Is draft'
17+
required: false
18+
default: 'false'
19+
includeDependabot:
20+
description: 'Include Dependabot PRs in release notes'
21+
required: false
22+
default: 'false'
23+
runs:
24+
using: 'docker'
25+
image: 'docker://ghcr.io/encoredigitalgroup/gh-action-create-github-release:latest'
26+
env:
27+
GH_TOKEN: ${{ secrets.token }}
28+
GH_REPOSITORY: ${{ github.repository }}
29+
TAG_NAME: ${{ github.ref_name }}
30+
PRE_RELEASE: ${{ inputs.preRelease }}
31+
GENERATE_RELEASE_NOTES: ${{ inputs.generateReleaseNotes }}
32+
IS_DRAFT: ${{ inputs.isDraft }}
33+
INCLUDE_DEPENDABOT: ${{ inputs.includeDependabot }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module github.com/EncoreDigitalGroup/ci-workflows/actions/github/formatPullRequestTitle
2+
3+
go 1.24.1
4+
5+
require (
6+
github.com/EncoreDigitalGroup/golib v0.1.5
7+
github.com/google/go-github/v70 v70.0.0
8+
golang.org/x/oauth2 v0.28.0
9+
)
10+
11+
require (
12+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
13+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
14+
github.com/charmbracelet/lipgloss v1.1.0 // indirect
15+
github.com/charmbracelet/log v0.4.1 // indirect
16+
github.com/charmbracelet/x/ansi v0.8.0 // indirect
17+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
18+
github.com/charmbracelet/x/term v0.2.1 // indirect
19+
github.com/go-logfmt/logfmt v0.6.0 // indirect
20+
github.com/google/go-querystring v1.1.0 // indirect
21+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
22+
github.com/mattn/go-isatty v0.0.20 // indirect
23+
github.com/mattn/go-runewidth v0.0.16 // indirect
24+
github.com/muesli/termenv v0.16.0 // indirect
25+
github.com/rivo/uniseg v0.4.7 // indirect
26+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
27+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
28+
golang.org/x/sys v0.30.0 // indirect
29+
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
github.com/EncoreDigitalGroup/golib v0.1.5 h1:o6l2ag515bkGXL2Nu+FvPuNYtZTznSRJUQCvCSR/UPg=
2+
github.com/EncoreDigitalGroup/golib v0.1.5/go.mod h1:QRvCXOZhxOJLJTPiOo5RSZdAIt0f8wV5mF8oasHJcIE=
3+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
4+
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
5+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
6+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
7+
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
8+
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
9+
github.com/charmbracelet/log v0.4.1 h1:6AYnoHKADkghm/vt4neaNEXkxcXLSV2g1rdyFDOpTyk=
10+
github.com/charmbracelet/log v0.4.1/go.mod h1:pXgyTsqsVu4N9hGdHmQ0xEA4RsXof402LX9ZgiITn2I=
11+
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
12+
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
13+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
14+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
15+
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
16+
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
17+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
18+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
19+
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
20+
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
21+
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
22+
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
23+
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
24+
github.com/google/go-github/v70 v70.0.0 h1:/tqCp5KPrcvqCc7vIvYyFYTiCGrYvaWoYMGHSQbo55o=
25+
github.com/google/go-github/v70 v70.0.0/go.mod h1:xBUZgo8MI3lUL/hwxl3hlceJW1U8MVnXP3zUyI+rhQY=
26+
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
27+
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
28+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
29+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
30+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
31+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
32+
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
33+
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
34+
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
35+
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
36+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
37+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
38+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
39+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
40+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
41+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
42+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
43+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
44+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
45+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
46+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
47+
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
48+
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
49+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
50+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
51+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
52+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
53+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
54+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)