Skip to content

Commit

Permalink
feat(await-maven-artifact): migrate from https:/elastic/a…
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Sep 12, 2024
1 parent d1cb99c commit 8da17a2
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test-maven-await-artifact.yml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions maven/await-artifact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# <!--name-->maven/await-artifact<!--/name-->

[![usages](https://img.shields.io/badge/usages-white?logo=githubactions&logoColor=blue)](https:/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:/elastic/oblt-actions/actions/workflows/test-elastic-active-branches.yml/badge.svg?branch=main)](https:/elastic/oblt-actions/actions/workflows/test-maven-await-artifact.yml)

<!--description-->
Waits for an artifact to be available on 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` | ` ` |
<!--/inputs-->


## Usage

<!--usage action="elastic/oblt-actions/**" version="env:VERSION"-->
```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 }}"
# ...
```
<!--/usage-->
29 changes: 29 additions & 0 deletions maven/await-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 8da17a2

Please sign in to comment.