Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
imageName: 'gh-action-json-diff-alert'
- actionPath: 'actions/github/enrichPullRequest'
imageName: 'gh-action-enrich-pull-request'
- actionPath: 'actions/github/formatPullRequestTitle'
imageName: 'gh-action-format-pull-request-title'
uses: ./.github/workflows/_github_createAndReleaseActionDockerImage.yml
with:
actionPath: ${{ matrix.actionPath }}
Expand Down
41 changes: 41 additions & 0 deletions actions/github/formatPullRequestTitle/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM golang:1.24-alpine AS builder

WORKDIR /app

# Copy go mod and sum files
COPY go.mod go.sum ./

# Download dependencies
RUN go mod download

# Copy source code
COPY main.go ./

# Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .

# Final stage - minimal image
FROM alpine:latest

# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates

# Create a non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup

# Set working directory
WORKDIR /app

# Copy the binary from builder stage
COPY --from=builder /app/main .

# Set ownership and permissions
RUN chown appuser:appgroup /app/main && \
chmod +x /app/main

# Switch to non-root user
USER appuser

# Run the binary
ENTRYPOINT ["/app/main"]
94 changes: 9 additions & 85 deletions actions/github/formatPullRequestTitle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,89 +25,13 @@ inputs:
required: false
default: false
type: boolean
runs:
using: 'composite'
steps:
- uses: actions/checkout@v4
with:
repository: ${{github.action_repository}}

- name: Setup Go
if: ${{ inputs.useGo }}
uses: actions/setup-go@v5
with:
go-version: '>=1.24.1'
go-version-file: '${{github.action_path}}/go.mod'
cache: true
cache-dependency-path: '${{github.action_path}}/go.sum'

- name: Generate Main Hash
id: mainHash
shell: bash
run: echo "hash=$(sha256sum ${{github.action_path}}/main.go | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT

- name: Generate Module Hash
id: moduleHash
shell: bash
run: echo "hash=$(sha256sum ${{github.action_path}}/go.sum | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT

- name: Restore Go Modules Cache
if: ${{ inputs.useGo }}
uses: actions/cache@v4
id: goModuleCache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-modules-${{ steps.moduleHash.outputs.hash }}

- name: Restore Binary Cache
if: ${{ inputs.useGo }}
uses: actions/cache@v4
id: binary-cache
with:
path: ${{github.action_path}}/action-binary
key: ${{ runner.os }}-go-binary-${{ steps.mainHash.outputs.hash }}

- name: Tidy Go Modules
if: ${{ inputs.useGo && steps.binary-cache.outputs.cache-hit != 'true' }}
shell: bash
working-directory: ${{github.action_path}}
run: go mod tidy

- name: Build Binary
if: ${{ inputs.useGo && steps.binary-cache.outputs.cache-hit != 'true' }}
shell: bash
working-directory: ${{github.action_path}}
run: go build -o ${{github.action_path}}/action-binary main.go

- name: Set Execute Permissions on Binary
if: ${{ inputs.useGo && steps.binary-cache.outputs.cache-hit == 'true' }}
shell: bash
working-directory: ${{github.action_path}}
run: chmod +x ${{github.action_path}}/action-binary

- name: "Format Pull Request Title"
if: ${{ inputs.useGo }}
shell: bash
working-directory: ${{github.action_path}}
run: ${{github.action_path}}/action-binary
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPOSITORY: ${{ inputs.repository }}
PR_NUMBER: ${{ inputs.pullRequestNumber }}
BRANCH_NAME: ${{ inputs.branch }}
CI_FMT_WORDS: ${{ inputs.customFormatting }}

- name: "Set execute permissions [NOTICE: This will be removed in the next major version]"
if: ${{ !inputs.useGo }}
shell: bash
run: chmod +x ${{github.action_path}}/entrypoint.sh

- name: "Format Pull Request Title (Legacy) [NOTICE: This will be removed in the next major version]"
if: ${{ !inputs.useGo }}
shell: bash
run: ${{github.action_path}}/entrypoint.sh
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPOSITORY: ${{ inputs.repository }}
PR_NUMBER: ${{ inputs.pullRequestNumber }}
BRANCH_NAME: ${{ inputs.branch }}
runs:
using: 'docker'
image: 'docker://ghcr.io/encoredigitalgroup/gh-action-format-pull-request-title:latest'
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPOSITORY: ${{ inputs.repository }}
PR_NUMBER: ${{ inputs.pullRequestNumber }}
BRANCH_NAME: ${{ inputs.branch }}
CI_FMT_WORDS: ${{ inputs.customFormatting }}
73 changes: 0 additions & 73 deletions actions/github/formatPullRequestTitle/entrypoint.sh

This file was deleted.