diff --git a/.github/workflows/test-maven-await-artifact.yml b/.github/workflows/test-maven-await-artifact.yml new file mode 100644 index 0000000..55d8d51 --- /dev/null +++ b/.github/workflows/test-maven-await-artifact.yml @@ -0,0 +1,28 @@ +name: test-maven-await-artifact + +on: + pull_request: + paths: + - 'maven/await-artifact/**' + - '.github/workflows/test-maven-await-artifact.yml' + push: + branches: + - main + paths: + - 'maven/await-artifact/**' + - '.github/workflows/test-maven-await-artifact.yml' + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./maven/await-artifact + timeout-minutes: 1 + with: + artifact-id: "elastic-apm-agent" + group-id: "co.elastic.apm" + version: "1.50.0" diff --git a/maven/await-artifact/README.md b/maven/await-artifact/README.md new file mode 100644 index 0000000..1fae5a4 --- /dev/null +++ b/maven/await-artifact/README.md @@ -0,0 +1,48 @@ +# maven/await-artifact + +[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https://github.com/search?q=elastic%2Foblt-actions%2Fmaven%2Fawait-artifact+%28path%3A.github%2Fworkflows+OR+path%3A**%2Faction.yml+OR+path%3A**%2Faction.yaml%29&type=code) +[![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) + + +Waits for an artifact to be available on maven central + + +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 + +| 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` | ` ` | + + + +## Usage + + +```yaml +name: release +on: + workflow_dispatch: + inputs: + version: + description: 'The version to release (e.g. 1.2.3). This workflow will automatically perform the required version bumps' + required: true +jobs: + + deploy: + runs-on: ubuntu-latest + steps: + # ... + - uses: elastic/oblt-actions/maven/await-artifact@v1 + timeout-minutes: 10 + with: + group-id: "co.elastic.apm" + artifact-id: "apm-agent-java" + version: "${{ inputs.version }}" + # ... +``` + diff --git a/maven/await-artifact/action.yml b/maven/await-artifact/action.yml new file mode 100644 index 0000000..54d4692 --- /dev/null +++ b/maven/await-artifact/action.yml @@ -0,0 +1,29 @@ +name: maven/await-artifact +description: | + Waits for an artifact to be available on maven central +inputs: + artifact-id: + description: 'Maven artifact-ID of the artifact' + required: true + group-id: + description: 'Maven group-ID of the artifact' + required: true + version: + description: 'Version of the artifact to wait for' + required: true +runs: + using: "composite" + steps: + - name: Wait for artifact to be available on maven central + shell: bash + run: | + 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 + done + env: + ARTIFACT_ID: ${{ inputs.artifact-id }} + GROUP_ID: ${{ inputs.group-id }} + VERSION: ${{ inputs.version }}