Skip to content

Commit 7fbc831

Browse files
authored
Fix docker maven url (#4158)
* Fix maven url in docker script * Add workflow allowing the re-generation of docker images * Add missing dry_run parameter, fix casing * Move checkout outside of composite action, as it is likely required
1 parent 734a628 commit 7fbc831

File tree

4 files changed

+79
-18
lines changed

4 files changed

+79
-18
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'Build and publish docker images'
2+
description: 'Builds and publishes the docker images for a given version using the agent artifact from maven central'
3+
inputs:
4+
release_version:
5+
description: 'The version to release. If this is the currently latest version based on the git tags, it will also be published as latest'
6+
required: true
7+
ref:
8+
description: 'Branch or tag ref to run the action, defines the version of the scripts in the ./scripts folder to run'
9+
required: true
10+
dry_run:
11+
description: If set, generate the docker image but don't publish it
12+
required: true
13+
type: boolean
14+
runs:
15+
using: "composite"
16+
env:
17+
SONATYPE_FALLBACK: 1
18+
steps:
19+
- name: Log in to the Elastic Container registry
20+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
21+
with:
22+
registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
23+
username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
24+
password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
25+
26+
- name: "Build docker image"
27+
shell: bash
28+
run: ./scripts/docker-release/build_docker.sh "${{ inputs.release_version }}"
29+
- name: "Push docker image"
30+
if: ${{ ! inputs.dry_run }}
31+
shell: bash
32+
run: ./scripts/docker-release/push_docker.sh "${{ inputs.release_version }}"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# Regenerate the docker images based on what is released at maven central if something went wrong during the standard release process
3+
name: 'regenerate-docker-images'
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
ref:
9+
description: 'Branch or tag ref to run the workflow on'
10+
required: true
11+
default: "main"
12+
version:
13+
description: |
14+
The version of the agent to re-generate and publish the docker images for (e.g. 1.2.3).
15+
If this is the latest tag (based on the selected ref), the image will also be published with the latest-tag.
16+
required: true
17+
dry_run:
18+
description: If set, generates the images but doesn't push them
19+
default: false
20+
type: boolean
21+
22+
permissions:
23+
contents: read
24+
25+
concurrency:
26+
group: ${{ github.workflow }}
27+
28+
jobs:
29+
build-and-push-docker-images:
30+
name: "Build and push docker images"
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
ref: ${{ inputs.ref }}
36+
fetch-depth: 0 # Load entire history as it is required for the push-script
37+
- uses: ./.github/actions/build-and-publish-docker
38+
with:
39+
release_version: ${{ inputs.version }}
40+
ref: ${{ inputs.ref }}
41+
dry_run: ${{ inputs.dry_run }}

.github/workflows/release-step-3.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,28 +129,16 @@ jobs:
129129
needs:
130130
- await-maven-central-artifact
131131
- create-github-release
132-
env:
133-
SONATYPE_FALLBACK: 1
134132
steps:
135133
- uses: actions/checkout@v4
136134
with:
137135
ref: ${{ inputs.ref }}
138136
fetch-depth: 0 # Load entire history as it is required for the push-script
139-
140-
- name: Log in to the Elastic Container registry
141-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
137+
- uses: ./.github/actions/build-and-publish-docker
142138
with:
143-
registry: ${{ secrets.ELASTIC_DOCKER_REGISTRY }}
144-
username: ${{ secrets.ELASTIC_DOCKER_USERNAME }}
145-
password: ${{ secrets.ELASTIC_DOCKER_PASSWORD }}
146-
147-
- name: "Build docker image"
148-
shell: bash
149-
run: ./scripts/docker-release/build_docker.sh "${{ env.RELEASE_VERSION }}"
150-
- name: "Push docker image"
151-
if: ${{ ! inputs.dry_run }}
152-
shell: bash
153-
run: ./scripts/docker-release/push_docker.sh "${{ env.RELEASE_VERSION }}"
139+
release_version: "${{ env.RELEASE_VERSION }}"
140+
ref: ${{ inputs.ref }}
141+
dry_run: ${{ inputs.dry_run }}
154142

155143
publish-aws-lambda:
156144
name: "Publish AWS Lambda"

scripts/docker-release/build_docker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ then
3434
then
3535
echo "ERROR: Pulling images from Sonatype Nexus repo requires cURL to be installed" && exit 1
3636
fi
37-
curl -L -s -o apm-agent-java.jar \
38-
"https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=co.elastic.apm&a=elastic-apm-agent&v=$RELEASE_VERSION"
37+
curl -L -s --fail-with-body -o apm-agent-java.jar \
38+
"https://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/$RELEASE_VERSION/elastic-apm-agent-$RELEASE_VERSION.jar"
3939
else
4040
echo "ERROR: No suitable build artifact was found. Re-running this script with the SONATYPE_FALLBACK variable set to true will try to use the Sonatype artifact for the latest tag"
4141
exit 1

0 commit comments

Comments
 (0)