Skip to content
Draft
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
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# 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
81 changes: 81 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Image

on:
workflow_call:
inputs:
image:
description: 'Image name (e.g. config-server)'
required: true
type: string
port:
description: 'Container port exposed by the image'
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:
- uses: actions/checkout@v4

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

- name: Login to container registry
uses: docker/login-action@v3
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@v7
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 ${{ inputs.port }}:${{ inputs.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,
});
}
77 changes: 12 additions & 65 deletions .github/workflows/build_config_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ on:
pull_request:
paths:
- '.github/workflows/build_config_server.yaml'
- '.github/workflows/build-image.yaml'
- 'config-server/metadata/*'
- 'config-server/patches/*'
- 'config-server/source/**'
- 'build.ps1'
push:
branches:
- main
paths:
- '.github/workflows/build_config_server.yaml'
- '.github/workflows/build-image.yaml'
- 'config-server/metadata/*'
- 'config-server/patches/*'
- 'config-server/source/**'
- 'build.ps1'

concurrency:
Expand All @@ -22,70 +26,13 @@ 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
port: '8888'
description: Spring Cloud Config Server
secrets: inherit
77 changes: 12 additions & 65 deletions .github/workflows/build_eureka_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ on:
pull_request:
paths:
- '.github/workflows/build_eureka_server.yaml'
- '.github/workflows/build-image.yaml'
- 'eureka-server/metadata/*'
- 'eureka-server/patches/*'
- 'eureka-server/source/**'
- 'build.ps1'
push:
branches:
- main
paths:
- '.github/workflows/build_eureka_server.yaml'
- '.github/workflows/build-image.yaml'
- 'eureka-server/metadata/*'
- 'eureka-server/patches/*'
- 'eureka-server/source/**'
- 'build.ps1'

concurrency:
Expand All @@ -22,70 +26,13 @@ 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
port: '8761'
description: Eureka Server
secrets: inherit
77 changes: 12 additions & 65 deletions .github/workflows/build_springboot_admin_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ on:
pull_request:
paths:
- '.github/workflows/build_springboot_admin_server.yaml'
- '.github/workflows/build-image.yaml'
- 'spring-boot-admin/metadata/*'
- 'spring-boot-admin/patches/*'
- 'spring-boot-admin/source/**'
- 'build.ps1'
push:
branches:
- main
paths:
- '.github/workflows/build_springboot_admin_server.yaml'
- '.github/workflows/build-image.yaml'
- 'spring-boot-admin/metadata/*'
- 'spring-boot-admin/patches/*'
- 'spring-boot-admin/source/**'
- 'build.ps1'

concurrency:
Expand All @@ -22,70 +26,13 @@ concurrency:

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

env:
IMAGE_NAME: spring-boot-admin
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_SPRING_BOOT_ADMIN -->';
const body = `${marker}
To run the Spring Boot Admin server image built for this pull request:
\`\`\`bash
docker run --rm -d --pull=always -p 9099:9099 --name sba-pr steeltoe.azurecr.io/spring-boot-admin: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: spring-boot-admin
port: '9099'
description: Spring Boot Admin Server
secrets: inherit
Loading
Loading