-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add Harbor CR upload action - Rename upload-action as upload-action-jfrog - Fix tag regular expression to support tags without endings Signed-off-by: Ivan Kuznetsov <[email protected]>
- Loading branch information
Showing
5 changed files
with
95 additions
and
13 deletions.
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,37 @@ | ||
# SPDX-FileCopyrightText: 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Push artifacts to Harbor artifactory | ||
description: Push artifacts to Harbor artifactory | ||
|
||
inputs: | ||
HARBOR_UNAME: | ||
description: 'user account for artifactory' | ||
required: true | ||
HARBOR_TOKEN: | ||
description: 'api-key for artifactory' | ||
required: true | ||
HARBOR_URL: | ||
description: 'artifactory url' | ||
required: true | ||
input-paths: | ||
description: 'input-paths' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Preparing artifactory for upload | ||
uses: oras-project/setup-oras@v1 | ||
- run: oras version | ||
shell: bash | ||
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH | ||
shell: bash | ||
- run: upload.sh | ||
env: | ||
HARBOR_UNAME: ${{ inputs.HARBOR_UNAME }} | ||
HARBOR_TOKEN: ${{ inputs.HARBOR_TOKEN }} | ||
HARBOR_URL: ${{ inputs.HARBOR_URL }} | ||
INPUT_PATHS: ${{ inputs.input-paths }} | ||
shell: bash |
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,47 @@ | ||
#!/bin/bash -e | ||
# SPDX-FileCopyrightText: 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
err_print() { | ||
printf "%s" "$*" >&2 | ||
} | ||
|
||
err_exit() { | ||
local rc=$1 | ||
shift | ||
err_print "$@" | ||
exit "$rc" | ||
} | ||
|
||
echo "::group::Input validation" | ||
|
||
[ ! "$HARBOR_URL" ] && err_exit 1 "HARBOR_URL undefined" | ||
[ ! "$HARBOR_UNAME" ] && err_exit 1 "HARBOR_UNAME undefined" | ||
[ ! "$HARBOR_TOKEN" ] && err_exit 1 "HARBOR_TOKEN undefined" | ||
|
||
for input in $INPUT_PATHS; do | ||
SOURCE_DIR=$(echo "$input" | cut -d ":" -f 1) | ||
DEST_DIR=$(echo "$input" | cut -d ":" -f 2) | ||
echo "SOURCE_DIR=$SOURCE_DIR" | ||
echo "DEST_DIR=$DEST_DIR" | ||
[ ! "$SOURCE_DIR" ] && err_exit 1 "SOURCE_DIR undefined" | ||
[ ! "$DEST_DIR" ] && err_exit 1 "DEST_DIR undefined" | ||
done | ||
|
||
echo "::endgroup::" | ||
echo "::group::Artifact upload" | ||
|
||
echo $HARBOR_TOKEN | oras login $HARBOR_URL -u $HARBOR_UNAME --password-stdin | ||
|
||
for input in $INPUT_PATHS; do | ||
SOURCE_DIR=$(echo "$input" | cut -d ":" -f 1) | ||
DEST_DIR=$(echo "$input" | cut -d ":" -f 2) | ||
TAG=$(echo "$input" | cut -d ":" -f 3) | ||
|
||
UPLOAD_DIR=$SOURCE_DIR | ||
echo "oras push "$HARBOR_URL/$DEST_DIR:$TAG" $UPLOAD_DIR" | ||
oras push --disable-path-validation "$HARBOR_URL/$DEST_DIR:$TAG" $UPLOAD_DIR | ||
done | ||
|
||
echo "::endgroup::" |
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
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