lf
This commit is contained in:
parent
34da23de0a
commit
c1e279e9f2
@ -1,80 +1,80 @@
|
|||||||
name: Close Milestone Issues
|
name: Close Milestone Issues
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
repo:
|
repo:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
milestone:
|
milestone:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
jobs:
|
jobs:
|
||||||
close_issues:
|
close_issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: List and close issues
|
- name: List and close issues
|
||||||
run: |
|
run: |
|
||||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||||
OWNER="greyhound"
|
OWNER="greyhound"
|
||||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||||
|
|
||||||
NEW_LABEL_ID="32"
|
NEW_LABEL_ID="32"
|
||||||
FILTER_LABEL_ID="37"
|
FILTER_LABEL_ID="37"
|
||||||
|
|
||||||
# Fetch milestones from the repository
|
# Fetch milestones from the repository
|
||||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||||
|
|
||||||
# Extract the ID of the ${{ inputs.milestone }} milestone
|
# Extract the ID of the ${{ inputs.milestone }} milestone
|
||||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestone }}") | .id')
|
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestone }}") | .id')
|
||||||
|
|
||||||
if [ -z "$update_milestone_id" ]; then
|
if [ -z "$update_milestone_id" ]; then
|
||||||
echo "No milestone named '${{ inputs.milestone }}' found. Exiting."
|
echo "No milestone named '${{ inputs.milestone }}' found. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reading the Issues with the given Milestone
|
# Reading the Issues with the given Milestone
|
||||||
echo "Milestone Id '$update_milestone_id'"
|
echo "Milestone Id '$update_milestone_id'"
|
||||||
echo "Reading issues with Url '$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestone=$update_milestone_id'"
|
echo "Reading issues with Url '$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestone=$update_milestone_id'"
|
||||||
issues=$(curl -s -H "Authorization: token $API_TOKEN" \
|
issues=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestones=$update_milestone_id")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues?state=open&milestones=$update_milestone_id")
|
||||||
|
|
||||||
for issue_number in $(echo "$issues" | jq -r '.[].number'); do
|
for issue_number in $(echo "$issues" | jq -r '.[].number'); do
|
||||||
echo "Processing issue #$issue_number"
|
echo "Processing issue #$issue_number"
|
||||||
|
|
||||||
# Debug: Output the full response for the current issue
|
# Debug: Output the full response for the current issue
|
||||||
issue_details=$(curl -s -H "Authorization: token $API_TOKEN" \
|
issue_details=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||||
echo "Issue details: $issue_details"
|
echo "Issue details: $issue_details"
|
||||||
|
|
||||||
# Get the current labels for the issue (now correctly parsing the JSON structure)
|
# Get the current labels for the issue (now correctly parsing the JSON structure)
|
||||||
current_labels=$(echo "$issue_details" | jq '[.labels[].id]')
|
current_labels=$(echo "$issue_details" | jq '[.labels[].id]')
|
||||||
|
|
||||||
# Check if the issue has the specific label you're filtering by
|
# Check if the issue has the specific label you're filtering by
|
||||||
has_filter_label=$(echo "$current_labels" | jq --argjson filter_label $FILTER_LABEL_ID 'index($filter_label) != null')
|
has_filter_label=$(echo "$current_labels" | jq --argjson filter_label $FILTER_LABEL_ID 'index($filter_label) != null')
|
||||||
|
|
||||||
if [ "$has_filter_label" = "true" ]; then
|
if [ "$has_filter_label" = "true" ]; then
|
||||||
echo "Issue #$issue_number has the label $FILTER_LABEL_ID and milestone ${{ inputs.milestone }}"
|
echo "Issue #$issue_number has the label $FILTER_LABEL_ID and milestone ${{ inputs.milestone }}"
|
||||||
|
|
||||||
# Debug: Output current labels
|
# Debug: Output current labels
|
||||||
echo "Current labels for issue #$issue_number: $current_labels"
|
echo "Current labels for issue #$issue_number: $current_labels"
|
||||||
|
|
||||||
# Update the issue
|
# Update the issue
|
||||||
updateResponse=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
updateResponse=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"state\": \"closed\"}" \
|
-d "{\"state\": \"closed\"}" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number")
|
||||||
echo "ISSUE update response: $updateResponse"
|
echo "ISSUE update response: $updateResponse"
|
||||||
|
|
||||||
# Update the issue labels
|
# Update the issue labels
|
||||||
labelResponse=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
labelResponse=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"labels\": [$NEW_LABEL_ID]}" \
|
-d "{\"labels\": [$NEW_LABEL_ID]}" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number/labels")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/issues/$issue_number/labels")
|
||||||
|
|
||||||
echo "ISSUE Label update response code: $labelResponse"
|
echo "ISSUE Label update response code: $labelResponse"
|
||||||
else
|
else
|
||||||
echo "Issue #$issue_number does not have the label $FILTER_LABEL_ID, skipping..."
|
echo "Issue #$issue_number does not have the label $FILTER_LABEL_ID, skipping..."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -1,58 +1,58 @@
|
|||||||
name: Milestone Rename
|
name: Milestone Rename
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
repo:
|
repo:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
currentName:
|
currentName:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
newName:
|
newName:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
jobs:
|
jobs:
|
||||||
rename:
|
rename:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Rename
|
- name: Rename
|
||||||
run: |
|
run: |
|
||||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||||
OWNER="greyhound"
|
OWNER="greyhound"
|
||||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||||
|
|
||||||
# Fetch milestones from the repository
|
# Fetch milestones from the repository
|
||||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||||
|
|
||||||
# Extract the ID of the ${{ inputs.currentName }} milestone
|
# Extract the ID of the ${{ inputs.currentName }} milestone
|
||||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.currentName }}") | .id')
|
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.currentName }}") | .id')
|
||||||
|
|
||||||
if [ -z "$update_milestone_id" ]; then
|
if [ -z "$update_milestone_id" ]; then
|
||||||
echo "No milestone named '${{ inputs.currentName }}' found. Exiting."
|
echo "No milestone named '${{ inputs.currentName }}' found. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Found '${{ inputs.currentName }}' milestone with ID: $update_milestone_id"
|
echo "Found '${{ inputs.currentName }}' milestone with ID: $update_milestone_id"
|
||||||
|
|
||||||
echo "Rename the '${{ inputs.currentName }}' milestone to '${{ inputs.newName }}"
|
echo "Rename the '${{ inputs.currentName }}' milestone to '${{ inputs.newName }}"
|
||||||
new_name="${{ inputs.newName }}"
|
new_name="${{ inputs.newName }}"
|
||||||
milestone_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
milestone_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"title\": \"$new_name\", \"state\": \"closed\"}" \
|
-d "{\"title\": \"$new_name\", \"state\": \"closed\"}" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones/$update_milestone_id")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones/$update_milestone_id")
|
||||||
|
|
||||||
echo "Renamed '${{ inputs.currentName }}' milestone to $new_name: $milestone_update"
|
echo "Renamed '${{ inputs.currentName }}' milestone to $new_name: $milestone_update"
|
||||||
|
|
||||||
# Create a new milestone named "${{ inputs.currentName }}"
|
# Create a new milestone named "${{ inputs.currentName }}"
|
||||||
|
|
||||||
milestone_data=$(jq -n \
|
milestone_data=$(jq -n \
|
||||||
--arg title "${{ inputs.currentName }}" \
|
--arg title "${{ inputs.currentName }}" \
|
||||||
'{"title": $title}')
|
'{"title": $title}')
|
||||||
|
|
||||||
response=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
response=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$milestone_data" \
|
-d "$milestone_data" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||||
|
|
||||||
echo "Created new '${{ inputs.currentName }}' milestone: $response"
|
echo "Created new '${{ inputs.currentName }}' milestone: $response"
|
@ -1,77 +1,77 @@
|
|||||||
name: Parse Version Number
|
name: Parse Version Number
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
outputs:
|
outputs:
|
||||||
major:
|
major:
|
||||||
description: "Major number"
|
description: "Major number"
|
||||||
value: ${{ jobs.parse.outputs.major }}
|
value: ${{ jobs.parse.outputs.major }}
|
||||||
minor:
|
minor:
|
||||||
description: "Minor number"
|
description: "Minor number"
|
||||||
value: ${{ jobs.parse.outputs.minor }}
|
value: ${{ jobs.parse.outputs.minor }}
|
||||||
patch:
|
patch:
|
||||||
description: "Patch number"
|
description: "Patch number"
|
||||||
value: ${{ jobs.parse.outputs.patch }}
|
value: ${{ jobs.parse.outputs.patch }}
|
||||||
build:
|
build:
|
||||||
description: "Build number"
|
description: "Build number"
|
||||||
value: ${{ jobs.parse.outputs.build }}
|
value: ${{ jobs.parse.outputs.build }}
|
||||||
tag:
|
tag:
|
||||||
description: "Tag"
|
description: "Tag"
|
||||||
value: ${{ jobs.parse.outputs.tag }}
|
value: ${{ jobs.parse.outputs.tag }}
|
||||||
releaseChannel:
|
releaseChannel:
|
||||||
description: "The release channel"
|
description: "The release channel"
|
||||||
value: ${{ jobs.parse.outputs.releaseChannel }}
|
value: ${{ jobs.parse.outputs.releaseChannel }}
|
||||||
simpleVersion:
|
simpleVersion:
|
||||||
description: "Simple Version output"
|
description: "Simple Version output"
|
||||||
value: ${{ jobs.parse.outputs.simpleVersion }}
|
value: ${{ jobs.parse.outputs.simpleVersion }}
|
||||||
buildVersion:
|
buildVersion:
|
||||||
description: "Build Version Output"
|
description: "Build Version Output"
|
||||||
value: ${{ jobs.parse.outputs.buildVersion }}
|
value: ${{ jobs.parse.outputs.buildVersion }}
|
||||||
jobs:
|
jobs:
|
||||||
parse:
|
parse:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
major: ${{ steps.parseStep.outputs.major }}
|
major: ${{ steps.parseStep.outputs.major }}
|
||||||
minor: ${{ steps.parseStep.outputs.minor }}
|
minor: ${{ steps.parseStep.outputs.minor }}
|
||||||
patch: ${{ steps.parseStep.outputs.patch }}
|
patch: ${{ steps.parseStep.outputs.patch }}
|
||||||
build: ${{ steps.parseStep.outputs.build }}
|
build: ${{ steps.parseStep.outputs.build }}
|
||||||
tag: ${{ steps.parseStep.outputs.tag }}
|
tag: ${{ steps.parseStep.outputs.tag }}
|
||||||
releaseChannel: ${{ steps.parseStep.outputs.releaseChannel }}
|
releaseChannel: ${{ steps.parseStep.outputs.releaseChannel }}
|
||||||
simpleVersion: ${{ steps.parseStep.outputs.simpleVersion }}
|
simpleVersion: ${{ steps.parseStep.outputs.simpleVersion }}
|
||||||
buildVersion: ${{ steps.parseStep.outputs.buildVersion }}
|
buildVersion: ${{ steps.parseStep.outputs.buildVersion }}
|
||||||
steps:
|
steps:
|
||||||
- id: parseStep
|
- id: parseStep
|
||||||
run: |
|
run: |
|
||||||
tag="${{ inputs.version }}"
|
tag="${{ inputs.version }}"
|
||||||
tag="${tag#refs/tags/}"
|
tag="${tag#refs/tags/}"
|
||||||
|
|
||||||
if [[ "$tag" == *"/"* ]]; then
|
if [[ "$tag" == *"/"* ]]; then
|
||||||
releaseChannel=$(echo "$tag" | cut -d'/' -f1)
|
releaseChannel=$(echo "$tag" | cut -d'/' -f1)
|
||||||
version=$(echo "$tag" | cut -d'/' -f2)
|
version=$(echo "$tag" | cut -d'/' -f2)
|
||||||
else
|
else
|
||||||
releaseChannel="beta"
|
releaseChannel="beta"
|
||||||
version="$tag"
|
version="$tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=$(echo "$tag" | sed 's|.*/||')
|
version=$(echo "$tag" | sed 's|.*/||')
|
||||||
|
|
||||||
IFS='.' read -r major minor patch build <<< "$version"
|
IFS='.' read -r major minor patch build <<< "$version"
|
||||||
|
|
||||||
if [ -z "$build" ]; then
|
if [ -z "$build" ]; then
|
||||||
build="0"
|
build="0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
simpleVersion="$major"."$minor"."$patch"."$build"
|
simpleVersion="$major"."$minor"."$patch"."$build"
|
||||||
buildVersion="$major"."$minor"."$patch"-build."$build"
|
buildVersion="$major"."$minor"."$patch"-build."$build"
|
||||||
|
|
||||||
echo "major=$major" >> $GITHUB_OUTPUT
|
echo "major=$major" >> $GITHUB_OUTPUT
|
||||||
echo "minor=$minor" >> $GITHUB_OUTPUT
|
echo "minor=$minor" >> $GITHUB_OUTPUT
|
||||||
echo "patch=$patch" >> $GITHUB_OUTPUT
|
echo "patch=$patch" >> $GITHUB_OUTPUT
|
||||||
echo "build=$build" >> $GITHUB_OUTPUT
|
echo "build=$build" >> $GITHUB_OUTPUT
|
||||||
echo "tag=$tag" >> $GITHUB_OUTPUT
|
echo "tag=$tag" >> $GITHUB_OUTPUT
|
||||||
echo "releaseChannel=$releaseChannel" >> $GITHUB_OUTPUT
|
echo "releaseChannel=$releaseChannel" >> $GITHUB_OUTPUT
|
||||||
echo "simpleVersion=$simpleVersion" >> $GITHUB_OUTPUT
|
echo "simpleVersion=$simpleVersion" >> $GITHUB_OUTPUT
|
||||||
echo "buildVersion=$buildVersion" >> $GITHUB_OUTPUT
|
echo "buildVersion=$buildVersion" >> $GITHUB_OUTPUT
|
@ -1,56 +1,56 @@
|
|||||||
name: Set Package Version
|
name: Set Package Version
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
branch:
|
branch:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
packagePath:
|
packagePath:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
jobs:
|
jobs:
|
||||||
SetVersion:
|
SetVersion:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Set
|
- name: Set
|
||||||
run: |
|
run: |
|
||||||
git pull origin HEAD:${{ inputs.branch }}
|
git pull origin HEAD:${{ inputs.branch }}
|
||||||
|
|
||||||
echo "Setting Version to ${{ inputs.version }}"
|
echo "Setting Version to ${{ inputs.version }}"
|
||||||
|
|
||||||
git_path=$(pwd)
|
git_path=$(pwd)
|
||||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||||
echo "Change Directory to ${{ inputs.packagePath }}"
|
echo "Change Directory to ${{ inputs.packagePath }}"
|
||||||
cd ${{ inputs.packagePath }}
|
cd ${{ inputs.packagePath }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
npm version --no-git-tag-version ${{ inputs.version }}
|
npm version --no-git-tag-version ${{ inputs.version }}
|
||||||
|
|
||||||
echo "Change Directory back to $git_path"
|
echo "Change Directory back to $git_path"
|
||||||
cd $git_path
|
cd $git_path
|
||||||
- name: Commit version change
|
- name: Commit version change
|
||||||
run: |
|
run: |
|
||||||
if git diff --quiet && git diff --cached --quiet; then
|
if git diff --quiet && git diff --cached --quiet; then
|
||||||
echo "No changes in the repository."
|
echo "No changes in the repository."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
package_name=package.json
|
package_name=package.json
|
||||||
if [ -n "${{ inputs.packagePath }}" ]; then
|
if [ -n "${{ inputs.packagePath }}" ]; then
|
||||||
package_name="${{ inputs.packagePath }}package.json"
|
package_name="${{ inputs.packagePath }}package.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
|
git config user.name "${{ vars.GIT_DEPLOY_NAME }}"
|
||||||
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
|
git config user.email "${{ vars.GIT_DEPLOY_MAIL }}"
|
||||||
|
|
||||||
git add $package_name
|
git add $package_name
|
||||||
git commit -m "Update package.json version to $TAG_VERSION"
|
git commit -m "Update package.json version to $TAG_VERSION"
|
||||||
|
|
||||||
- name: Push changes back to repository
|
- name: Push changes back to repository
|
||||||
run: |
|
run: |
|
||||||
git push origin HEAD:${{ inputs.branch }}
|
git push origin HEAD:${{ inputs.branch }}
|
@ -1,100 +1,100 @@
|
|||||||
name: Update Release
|
name: Update Release
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
milestoneName:
|
milestoneName:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
repo:
|
repo:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
artifactName:
|
artifactName:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
fileName:
|
fileName:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
jobs:
|
jobs:
|
||||||
UpdateRelease:
|
UpdateRelease:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Load Artifact
|
- name: Load Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.artifactName }}
|
name: ${{ inputs.artifactName }}
|
||||||
path: ./
|
path: ./
|
||||||
|
|
||||||
- name: Get Release
|
- name: Get Release
|
||||||
run: |
|
run: |
|
||||||
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
|
||||||
OWNER="greyhound"
|
OWNER="greyhound"
|
||||||
API_TOKEN=${{ vars.PAT_TOKEN }}
|
API_TOKEN=${{ vars.PAT_TOKEN }}
|
||||||
|
|
||||||
# Fetch Release
|
# Fetch Release
|
||||||
tag=$(echo "${{ inputs.tag }}" | sed 's/\//%2F/g')
|
tag=$(echo "${{ inputs.tag }}" | sed 's/\//%2F/g')
|
||||||
|
|
||||||
release=$(curl -s -H "Authorization: token $API_TOKEN" \
|
release=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/tags/$tag")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/tags/$tag")
|
||||||
|
|
||||||
# Extract the ID of the Release
|
# Extract the ID of the Release
|
||||||
release_id=$(echo $release | jq -r '.id')
|
release_id=$(echo $release | jq -r '.id')
|
||||||
|
|
||||||
if [ "$release_id" == "null" ]; then
|
if [ "$release_id" == "null" ]; then
|
||||||
echo "No release for tag '${{ inputs.tag }}' found. Exiting."
|
echo "No release for tag '${{ inputs.tag }}' found. Exiting."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Found tag '${{ inputs.tag }}' release with ID: $release_id"
|
echo "Found tag '${{ inputs.tag }}' release with ID: $release_id"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
milestones=$(curl -s -H "Authorization: token $API_TOKEN" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/milestones")
|
||||||
|
|
||||||
echo "Milestones: $milestones."
|
echo "Milestones: $milestones."
|
||||||
|
|
||||||
# Extract the ID of the ${{ inputs.milestoneName }} milestone
|
# Extract the ID of the ${{ inputs.milestoneName }} milestone
|
||||||
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestoneName }}") | .id')
|
update_milestone_id=$(echo "$milestones" | jq '.[] | select(.title == "${{ inputs.milestoneName }}") | .id')
|
||||||
|
|
||||||
if [ "$update_milestone_id" != "null" ]; then
|
if [ "$update_milestone_id" != "null" ]; then
|
||||||
echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id."
|
echo "Milestone named '${{ inputs.milestoneName }}' found with id $update_milestone_id."
|
||||||
|
|
||||||
description="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id"
|
description="https://gitea.greyhound-software.com/$OWNER/${{ inputs.repo }}/milestone/$update_milestone_id"
|
||||||
|
|
||||||
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"body\": \"$description\", \"name\": \"${{ inputs.milestoneName }}\"}" \
|
-d "{\"body\": \"$description\", \"name\": \"${{ inputs.milestoneName }}\"}" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${{ inputs.artifactName }}" != "null" ]; then
|
if [ "${{ inputs.artifactName }}" != "null" ]; then
|
||||||
artifact_file="./${{ inputs.fileName }}"
|
artifact_file="./${{ inputs.fileName }}"
|
||||||
artifact_name=$(basename "$artifact_file")
|
artifact_name=$(basename "$artifact_file")
|
||||||
|
|
||||||
echo "Checking artifact '$artifact_file'"
|
echo "Checking artifact '$artifact_file'"
|
||||||
if [ -f "$artifact_file" ]; then
|
if [ -f "$artifact_file" ]; then
|
||||||
echo "Uploading artifact '$artifact_name' to release $release_id..."
|
echo "Uploading artifact '$artifact_name' to release $release_id..."
|
||||||
|
|
||||||
upload_response=$(curl -s -o response.json -w "%{http_code}" -X POST \
|
upload_response=$(curl -s -o response.json -w "%{http_code}" -X POST \
|
||||||
-H "Authorization: token $API_TOKEN" \
|
-H "Authorization: token $API_TOKEN" \
|
||||||
-H "Content-Type: multipart/form-data" \
|
-H "Content-Type: multipart/form-data" \
|
||||||
-F "name=$artifact_name" \
|
-F "name=$artifact_name" \
|
||||||
-F "attachment=@$artifact_file" \
|
-F "attachment=@$artifact_file" \
|
||||||
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id/assets")
|
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id/assets")
|
||||||
|
|
||||||
http_code=$(echo "$upload_response" | tail -n1) # Last line is the HTTP code
|
http_code=$(echo "$upload_response" | tail -n1) # Last line is the HTTP code
|
||||||
if [ "$http_code" -ne 201 ]; then
|
if [ "$http_code" -ne 201 ]; then
|
||||||
echo "Artifact upload failed with HTTP code: $http_code"
|
echo "Artifact upload failed with HTTP code: $http_code"
|
||||||
echo "Response: $(cat response.json)"
|
echo "Response: $(cat response.json)"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Artifact uploaded successfully."
|
echo "Artifact uploaded successfully."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Artifact file '$artifact_file' not found. Exiting."
|
echo "Artifact file '$artifact_file' not found. Exiting."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
@ -1,50 +1,53 @@
|
|||||||
name: Upload artifact With Ftp
|
name: Upload artifact With Ftp
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
artifactName:
|
artifactName:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
fileName:
|
fileName:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
uploadName:
|
uploadName:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
ftpPath:
|
ftpPath:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
txtFileContent:
|
txtFileContent:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
txtFileName:
|
txtFileName:
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
jobs:
|
jobs:
|
||||||
UploadFtp:
|
UploadFtp:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Load Artifact
|
- name: Load Artifact
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.artifactName }}
|
name: ${{ inputs.artifactName }}
|
||||||
path: ./
|
path: ./
|
||||||
- name: Upload
|
- name: Upload
|
||||||
run: |
|
run: |
|
||||||
upload_name=${{ inputs.fileName }}
|
upload_name=${{ inputs.fileName }}
|
||||||
|
|
||||||
if [ "${{ inputs.uploadName }}" != "" ]; then
|
if [ "${{ inputs.uploadName }}" != "" ]; then
|
||||||
echo "Renaming file to ${{ inputs.uploadName }}"
|
echo "Renaming file to ${{ inputs.uploadName }}"
|
||||||
mv ${{ inputs.fileName }} ${{ inputs.uploadName }}
|
mv ${{ inputs.fileName }} ${{ inputs.uploadName }}
|
||||||
upload_name=${{ inputs.uploadName }}
|
upload_name=${{ inputs.uploadName }}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Uploading $upload_name"
|
echo "Uploading $upload_name"
|
||||||
curl -T ./$upload_name ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
curl -T ./$upload_name ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||||
echo "Uploading finished $upload_name"
|
echo "Uploading finished $upload_name"
|
||||||
|
|
||||||
if [ "${{ inputs.txtFileName }}" != "" ]; then
|
echo "TXT Filename is ${{ inputs.txtFileName }}"
|
||||||
echo "Uploading additional Text File ${{ inputs.txtFileName }}"
|
if [ "${{ inputs.txtFileName }}" != "" ]; then
|
||||||
printf "%b" "${{ inputs.txtFileContent }}" > ${{ inputs.txtFileName }}
|
echo "Uploading additional Text File ${{ inputs.txtFileName }}"
|
||||||
curl -T ./${{ inputs.txtFileName }} ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
printf "%b" "${{ inputs.txtFileContent }}" > ${{ inputs.txtFileName }}
|
||||||
fi
|
curl -T ./${{ inputs.txtFileName }} ${{ vars.FTP_SERVER_URL }}${{ inputs.ftpPath }} --user "${{ vars.FTP_USER }}:${{ vars.FTP_PASSWORD }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Ftp Upload done"
|
Loading…
Reference in New Issue
Block a user