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
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Patches are applied on files extracted from a downloaded zip file. All these files use LF line endings.
*.patch text eol=lf

# Spring Initializr generates source files with LF line endings (Linux server).
# Explicit rules here prevent unexpected diffs when update-project.ps1 regenerates source on Windows,
# where core.autocrlf would otherwise convert committed files to CRLF on checkout.
**/source/**/*.java text eol=lf
**/source/**/*.gradle text eol=lf
**/source/**/*.properties text eol=lf
**/source/**/*.md text eol=lf
**/source/**/*.txt text eol=lf
**/source/**/*.xml text eol=lf
**/source/**/gradlew text eol=lf
**/source/**/gradlew.bat text eol=crlf
**/source/**/*.jar binary

# Customizations are appended/overlaid onto the generated (LF) source by update-project.ps1,
# so keep them LF to avoid introducing CRLF when regenerating on Windows.
**/customizations/build.gradle.append text eol=lf
**/customizations/overlay/**/*.java text eol=lf
97 changes: 97 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build Image

on:
workflow_call:
inputs:
image:
description: 'Image name (for example: config-server)'
required: true
type: string
description:
description: 'Human-readable image description for PR comments'
required: true
type: string

jobs:
build-push:
name: Build and push image
runs-on: ubuntu-latest
env:
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'edge' }}
REGISTRY: ${{ vars.DOCKER_REGISTRY }}

steps:
- name: Git checkout
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Read image config
id: config
shell: bash
run: echo "port=$(cat '${{ inputs.image }}/metadata/PORT' | tr -d '[:space:]')" >> $GITHUB_OUTPUT

- name: Set up JDK 25
if: inputs.image != 'uaa-server'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '25'
cache: gradle

- name: Build image
shell: pwsh
run: ./build.ps1 -Name '${{ inputs.image }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'

- name: Smoke test image
shell: pwsh
run: ./smoke-test.ps1 -Name '${{ inputs.image }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'

- name: Login to container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push image
run: docker push ${{ env.REGISTRY }}/${{ inputs.image }}:${{ env.TAG }}

- name: Post or update PR comment with image run instructions
uses: actions/github-script@v9
if: ${{ github.event_name == 'pull_request' }}
with:
script: |
const marker = '<!-- IMAGE_INSTRUCTIONS_${{ inputs.image }} -->';
const body = `${marker}
To run the ${{ inputs.description }} image built for this pull request:
\`\`\`bash
docker run --rm -d --pull=always -p ${{ steps.config.outputs.port }}:${{ steps.config.outputs.port }} --name ${{ inputs.image }}-pr ${{ env.REGISTRY }}/${{ inputs.image }}:${{ env.TAG }}
\`\`\``;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});

const existingComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' && comment.body.startsWith(marker)
);

if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
82 changes: 13 additions & 69 deletions .github/workflows/build_config_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ on:
pull_request:
paths:
- '.github/workflows/build_config_server.yaml'
- 'config-server/metadata/*'
- 'config-server/patches/*'
- '.github/workflows/build-image.yaml'
- 'config-server/**'
- '!config-server/README.md'
- 'build.ps1'
push:
branches:
- main
paths:
- '.github/workflows/build_config_server.yaml'
- 'config-server/metadata/*'
- 'config-server/patches/*'
- '.github/workflows/build-image.yaml'
- 'config-server/**'
- '!config-server/README.md'
- 'build.ps1'

concurrency:
Expand All @@ -22,70 +24,12 @@ concurrency:

permissions:
contents: read
pull-requests: 'write'

env:
IMAGE_NAME: config-server
REGISTRY: ${{ vars.DOCKER_REGISTRY }}
pull-requests: write

jobs:
build-push:
name: Build and push image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ vars.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push image
run: docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Post or update PR comment with image run instructions
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
script: |
const marker = '<!-- IMAGE_INSTRUCTIONS_CONFIG_SERVER -->';
const body = `${marker}
To run the Spring Cloud Config Server image built for this pull request:
\`\`\`bash
docker run --rm -d --pull=always -p 8888:8888 --name config-pr steeltoe.azurecr.io/config-server:pr-${{ github.event.number }}
\`\`\``;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});

const existingComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' && comment.body.startsWith(marker)
);

if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
build:
uses: ./.github/workflows/build-image.yaml
with:
image: config-server
description: Spring Cloud Config Server
secrets: inherit
82 changes: 13 additions & 69 deletions .github/workflows/build_eureka_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ on:
pull_request:
paths:
- '.github/workflows/build_eureka_server.yaml'
- 'eureka-server/metadata/*'
- 'eureka-server/patches/*'
- '.github/workflows/build-image.yaml'
- 'eureka-server/**'
- '!eureka-server/README.md'
- 'build.ps1'
push:
branches:
- main
paths:
- '.github/workflows/build_eureka_server.yaml'
- 'eureka-server/metadata/*'
- 'eureka-server/patches/*'
- '.github/workflows/build-image.yaml'
- 'eureka-server/**'
- '!eureka-server/README.md'
- 'build.ps1'

concurrency:
Expand All @@ -22,70 +24,12 @@ concurrency:

permissions:
contents: read
pull-requests: 'write'

env:
IMAGE_NAME: eureka-server
REGISTRY: ${{ vars.DOCKER_REGISTRY }}
pull-requests: write

jobs:
build-push:
name: Build and push image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build Image
run: ./build.ps1 -Name '${{ env.IMAGE_NAME }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}'
shell: pwsh
env:
TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ vars.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push image
run: docker push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Post or update PR comment with image run instructions
uses: actions/github-script@v7
if: ${{ github.event_name == 'pull_request' }}
with:
script: |
const marker = '<!-- IMAGE_INSTRUCTIONS_EUREKA_SERVER -->';
const body = `${marker}
To run the Eureka server image built for this pull request:
\`\`\`bash
docker run --rm -d --pull=always -p 8761:8761 --name eureka-pr steeltoe.azurecr.io/eureka-server:pr-${{ github.event.number }}
\`\`\``;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});

const existingComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' && comment.body.startsWith(marker)
);

if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
build:
uses: ./.github/workflows/build-image.yaml
with:
image: eureka-server
description: Spring Cloud Netflix Eureka Server
secrets: inherit
Loading