Skip to content

Commit

Permalink
Merge pull request #53 from scality/feature/check_artifacts_status_in…
Browse files Browse the repository at this point in the history
…_tag_version_check

Check artifacts are successfull on tag/version check
  • Loading branch information
Alexandre Lavigne authored Feb 22, 2023
2 parents 66b8171 + 557d9aa commit f0f2b1a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 1 deletion.
18 changes: 18 additions & 0 deletions action-check-tag-version/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ inputs:
artifacts-to-promote:
required: true
description: artifacts name to promote
artifacts-user:
required: true
description: artifacts username
artifacts-password:
required: true
description: artifacts password

runs:
using: "composite"
Expand Down Expand Up @@ -46,6 +52,18 @@ runs:
echo "HEAD commit: $HEAD_COMMIT" >&2
exit 1
fi
- name: Ensure artifacts are successfull
shell: bash
run: |
ARTIFACT_SUCCESS=$(curl \
--fail \
-L \
-u ${{ inputs. artifacts-user }}:${{ inputs.artifacts-password }} \
https://artifacts.scality.net/builds/${{ inputs.artifacts-to-promote }}/.final_status)
if [[ "$ARTIFACT_SUCCESS" != "SUCCESSFUL" ]]; then
echo "given artifacts are not successful artifacts" >&2
exit 1
fi
- name: Ensure tag matches local version
shell: bash
run: |
Expand Down
85 changes: 85 additions & 0 deletions action-check-tag-version/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Check tag, artifacts and version match

## Overview

This action takes care of checking that the following informations
match all together:

- tag:
- matches the repository version
- does not already exists
- matches the branch where the release is being run
- version:
- matches the given tag
- artifacts:
- the commit used to produce the artifacts matches the current branch HEAD
- the artifacts are successfull

This action ensures a clean release (no failed artifacts, no attemps to push an existent tag,...)

## Usage

This action is intended to be used in release process.

The action requires the artifacts `username` and `password` in order to check the artifacts status.

### Inputs

| Name | Description | Required |
|----------------------|-------------------------------|----------|
| tag | The tag to be released ||
| version | The version to be released ||
| artifacts-to-promote | The artifacts to promote ||
| artifacts-user | The artifacts username ||
| artifacts-password | The artifacts password ||

## Example

Here is an example of a workflow that uses that action.
The workflow example works as follow:

```yaml
name: release

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to be released'
required: true
artifacts-to-promote:
description: 'Artifacts name to promote'
required: true

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags
- name: Get current version
id: version
run: |
source ./VERSION
echo "VERSION=${VERSION}" >> ${GITHUB_OUTPUT}
- name: Check version and tag
uses: scality/actions/[email protected]
with:
tag: ${{ inputs.tag }}
version: ${{ steps.version.outputs.VERSION }}
artifacts-to-promote: ${{ inputs.artifacts-to-promote }}
artifacts-user: ${{ secrets.ARTIFACTS_USER }}
artifacts-password: ${{ secrets.ARTFICATS_PASSWORD }}
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.tag }}
name: Release ${{ inputs.tag }}
generate_release_notes: true
target_commitish: ${{ github.sha }}

```
2 changes: 1 addition & 1 deletion upload_final_status/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
description: The artifact password to upload the status
required: true
JOBS_RESULTS:
descript: Concatenation of jobs results
description: Concatenation of jobs results
required: true

runs:
Expand Down

0 comments on commit f0f2b1a

Please sign in to comment.