-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
120f6bb
commit 3a9243f
Showing
6 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Close Nexus staging repository | ||
description: Close a Nexus Staging Repository | ||
inputs: | ||
wait-for-completion: | ||
description: Whether the action should wait for the closure to complete before returning | ||
required: false | ||
default: 'true' | ||
max-await-attempts: | ||
description: Max attempts while waiting for the repository to close | ||
required: false | ||
default: '12' | ||
await-sleep-time: | ||
description: Time in seconds between two attempts to verify if the staging repository has been closed | ||
required: false | ||
default: '5' | ||
version: | ||
description: Version being released. Used to update the repository description while closing the staging repository | ||
required: true | ||
staging-repository: | ||
description: The id of the staging repository to be closed | ||
required: true | ||
nexus-username: | ||
description: The Nexus username | ||
required: true | ||
nexus-password: | ||
description: The Nexus password | ||
required: true | ||
nexus-url: | ||
description: The base URL to the Nexus server | ||
required: false | ||
default: "https://artifacts.alfresco.com/nexus" | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Close staging repository | ||
shell: bash | ||
env: | ||
WAIT_FOR_COMPLETION: ${{ inputs.wait-for-completion }} | ||
MAX_AWAIT_ATTEMPTS: ${{ inputs.max-await-attempts }} | ||
AWAIT_SLEEP_TIME: ${{ inputs.await-sleep-time }} | ||
NEXUS_USERNAME: ${{ inputs.nexus-username }} | ||
NEXUS_PASSWORD: ${{ inputs.nexus-password }} | ||
NEXUS_URL: ${{ inputs.nexus-url }} | ||
VERSION: ${{ inputs.version }} | ||
STAGING_REPOSITORY_ID: ${{ inputs.staging-repository }} | ||
run: | | ||
CLOSE_STAGING_PAYLOAD_CONTENT=$(envsubst < $GITHUB_ACTION_PATH/close-payload-template.json) | ||
curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d "$CLOSE_STAGING_PAYLOAD_CONTENT" \ | ||
"${NEXUS_URL}"/service/local/staging/bulk/close | ||
wait_until_true () { | ||
local attempt_counter=0 | ||
until "$@" | ||
do | ||
if [ ${attempt_counter} -eq ${MAX_AWAIT_ATTEMPTS} ] | ||
then | ||
echo "Max attempts reached. Exiting..." | ||
exit 1 | ||
fi | ||
attempt_counter=$((attempt_counter+1)) | ||
echo "Condition not reached yet. Attempt $attempt_counter out of $MAX_AWAIT_ATTEMPTS. Retrying..." | ||
sleep $AWAIT_SLEEP_TIME | ||
done | ||
} | ||
staging_repo_is_closed () { | ||
curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ | ||
-X GET "${NEXUS_URL}"/service/local/staging/profile_repositories \ | ||
| yq -p=xml e '.stagingRepositories.data.stagingProfileRepository[]| select (.repositoryId == env(STAGING_REPOSITORY_ID)) | .type ' \ | ||
| grep closed > /dev/null 2>&1 | ||
} | ||
if [[ "$WAIT_FOR_COMPLETION" == "true" ]] | ||
then | ||
echo "Waiting for staging repository $STAGING_REPOSITORY_ID to get closed. | ||
MAX_AWAIT_ATTEMPTS: $MAX_AWAIT_ATTEMPTS, AWAIT_SLEEP_TIME: $AWAIT_SLEEP_TIME ..." | ||
wait_until_true staging_repo_is_closed | ||
echo "Repository $STAGING_REPOSITORY_ID successfully closed!" | ||
fi |
8 changes: 8 additions & 0 deletions
8
.github/actions/nexus-close-staging/close-payload-template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"data": { | ||
"description": "Closing $VERSION", | ||
"stagedRepositoryIds": [ | ||
"$STAGING_REPOSITORY_ID" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Release Nexus staging repository | ||
description: Release a Nexus Staging Repository. The stage repository should be in the closed status. | ||
inputs: | ||
wait-for-completion: | ||
description: Whether the action should wait for the release to complete before returning | ||
required: false | ||
default: 'true' | ||
max-await-attempts: | ||
description: Max attempts while waiting for the repository to release | ||
required: false | ||
default: '12' | ||
await-sleep-time: | ||
description: Time in seconds between two attempts to verify if the staging repository has been released | ||
required: false | ||
default: '5' | ||
version: | ||
description: Version being released. Used to update the repository description while closing and releasing | ||
required: true | ||
staging-repository: | ||
description: The id of the staging repository to be promoted | ||
required: true | ||
nexus-username: | ||
description: The Nexus username | ||
required: true | ||
nexus-password: | ||
description: The Nexus password | ||
required: true | ||
nexus-url: | ||
description: The base URL to the Nexus server | ||
required: false | ||
default: "https://artifacts.alfresco.com/nexus" | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Release staging repository | ||
shell: bash | ||
env: | ||
WAIT_FOR_COMPLETION: ${{ inputs.wait-for-completion }} | ||
MAX_AWAIT_ATTEMPTS: ${{ inputs.max-await-attempts }} | ||
AWAIT_SLEEP_TIME: ${{ inputs.await-sleep-time }} | ||
NEXUS_USERNAME: ${{ inputs.nexus-username }} | ||
NEXUS_PASSWORD: ${{ inputs.nexus-password }} | ||
NEXUS_URL: ${{ inputs.nexus-url }} | ||
VERSION: ${{ inputs.version }} | ||
STAGING_REPOSITORY_ID: ${{ inputs.staging-repository }} | ||
run: | | ||
PROMOTE_PAYLOAD_CONTENT=$(envsubst < $GITHUB_ACTION_PATH/promote-payload-template.json) | ||
curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d "$PROMOTE_PAYLOAD_CONTENT" \ | ||
"${NEXUS_URL}"/service/local/staging/bulk/promote | ||
wait_until_released () { | ||
local attempt_counter=0 | ||
until [ -z "$(curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ | ||
-X GET "${NEXUS_URL}"/service/local/staging/profile_repositories \ | ||
| yq -p=xml e '.stagingRepositories.data.stagingProfileRepository[]| select (.repositoryId == env(STAGING_REPOSITORY_ID))')" ] | ||
do | ||
if [ ${attempt_counter} -eq ${MAX_AWAIT_ATTEMPTS} ] | ||
then | ||
echo "Max attempts reached. Exiting..." | ||
exit 1 | ||
fi | ||
attempt_counter=$((attempt_counter+1)) | ||
echo "Condition not reached yet. Attempt $attempt_counter out of $MAX_AWAIT_ATTEMPTS. Retrying..." | ||
sleep $AWAIT_SLEEP_TIME | ||
done | ||
} | ||
if [[ "$WAIT_FOR_COMPLETION" == "true" ]] | ||
then | ||
echo "Waiting for staging repository $STAGING_REPOSITORY_ID to get released. | ||
MAX_AWAIT_ATTEMPTS: $MAX_AWAIT_ATTEMPTS, AWAIT_SLEEP_TIME: $AWAIT_SLEEP_TIME ..." | ||
wait_until_released | ||
echo "Repository $STAGING_REPOSITORY_ID successfully released!" | ||
fi |
9 changes: 9 additions & 0 deletions
9
.github/actions/nexus-release-staging/promote-payload-template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"data": { | ||
"autoDropAfterRelease": true, | ||
"description": "Releasing $VERSION", | ||
"stagedRepositoryIds": [ | ||
"$STAGING_REPOSITORY_ID" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters