Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support wait for maven central #133

Merged
merged 8 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
14 changes: 8 additions & 6 deletions maven/await-artifact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
[![test-maven-await-artifact](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-active-branches.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-maven-await-artifact.yml)

<!--description-->
Waits for an artifact to be available on maven central
Waits for an artifact to be available on maven central or the sonatype proxy maven central.
<!--/description-->

NOTE: this action does not timeout, hence you need to configure your GitHub workflow accordingly.
See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes

## Inputs
<!--inputs-->
| Name | Description | Required | Default |
|---------------|-------------------------------------|----------|---------|
| `artifact-id` | Maven artifact-ID of the artifact | `true` | ` ` |
| `group-id` | Maven group-ID of the artifact | `true` | ` ` |
| `version` | Version of the artifact to wait for | `true` | ` ` |
| Name | Description | Required | Default |
|-----------------------------|--------------------------------------------------------------------------------------|----------|---------|
| `artifact-id` | Maven artifact-ID of the artifact | `true` | ` ` |
| `group-id` | Maven group-ID of the artifact | `true` | ` ` |
| `version` | Version of the artifact to wait for | `true` | ` ` |
| `wait-for-sonatype-central` | Whether to wait for the artifact to be available in the sonatype central repository. | `false` | `true` |
| `wait-for-maven-central` | Whether to wait for the artifact to be available in the maven central repository. | `false` | `false` |
v1v marked this conversation as resolved.
Show resolved Hide resolved
<!--/inputs-->


Expand Down
35 changes: 31 additions & 4 deletions maven/await-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: maven/await-artifact
description: |
Waits for an artifact to be available on maven central
Waits for an artifact to be available on maven central or the sonatype proxy maven central.
v1v marked this conversation as resolved.
Show resolved Hide resolved
inputs:
artifact-id:
description: 'Maven artifact-ID of the artifact'
Expand All @@ -11,17 +11,44 @@ inputs:
version:
description: 'Version of the artifact to wait for'
required: true
wait-for-sonatype-central:
description: 'Whether to wait for the artifact to be available in the sonatype central repository.'
default: true
required: false
wait-for-maven-central:
v1v marked this conversation as resolved.
Show resolved Hide resolved
description: 'Whether to wait for the artifact to be available in the maven central repository.'
default: false
required: false
runs:
using: "composite"
steps:
- name: Wait for artifact to be available on maven central
- name: Wait for artifact to be available on proxy sonatype maven central
if: ${{ inputs.wait-for-sonatype-central == 'true' }}
v1v marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
run: |
TIME=30
full_url="https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=${GROUP_ID}&a=${ARTIFACT_ID}&v=${VERSION}"
until curl -fs -I -L "${full_url}" > /dev/null
do
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on maven central. Sleeping 30 seconds, retrying afterwards"
sleep 30s
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on proxy maven central. Sleeping ${WAIT_SECONDS} seconds, retrying afterwards"
sleep ${WAIT_SECONDS}s
done
env:
ARTIFACT_ID: ${{ inputs.artifact-id }}
GROUP_ID: ${{ inputs.group-id }}
VERSION: ${{ inputs.version }}

- name: Wait for artifact to be available on maven central
if: ${{ inputs.wait-for-maven-central == 'true' }}
v1v marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
run: |
TIME=30
GROUP_FOLDER="${GROUP_ID//.//}"
full_url="https://repo.maven.apache.org/maven2/${GROUP_FOLDER}/${ARTIFACT_ID}/${VERSION}"
until curl -fs -I -L "${full_url}" > /dev/null
do
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on maven central. Sleeping ${WAIT_SECONDS} seconds, retrying afterwards"
sleep ${WAIT_SECONDS}s
done
env:
ARTIFACT_ID: ${{ inputs.artifact-id }}
Expand Down
Loading