0
0
This commit is contained in:
Marco Maatz 2025-05-20 09:09:10 +02:00
parent 3b37023209
commit 642480e6dc
3 changed files with 93 additions and 2 deletions

View File

@ -0,0 +1,37 @@
name: Get Release Channel
on:
workflow_call:
inputs:
tag:
required: true
type: string
outputs:
buildChannel:
description: "The current Release Build channel"
value: ${{ jobs.read.outputs.buildChannel }}
jobs:
read:
runs-on: ubuntu-latest
outputs:
buildChannel: ${{ steps.readRelease.outputs.buildChannel }}
steps:
- id: readRelease
run: |
GITEA_API_URL="https://gitea.greyhound-software.com/api/v1"
OWNER="greyhound"
API_TOKEN=${{ vars.PAT_TOKEN }}
### RELEASE ###
# Read Release and Extract the ID
tag=$(echo "${{ inputs.tag }}" | sed 's/\//%2F/g')
release=$(curl -s -H "Authorization: token $API_TOKEN" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/tags/$tag")
echo "Release Read $release"
release_body=$(echo $release | jq -r '.body')
echo "Release Body $release_body"
echo "buildChannel=$buildChannel" >> $GITHUB_OUTPUT

View File

@ -0,0 +1,54 @@
name: Send Promote Mail
on:
workflow_call:
inputs:
oldChannel:
required: true
type: string
newChannel:
required: true
type: string
tag:
required: true
type: string
jobs:
Mail:
runs-on: ubuntu-latest
steps:
- name: Install Mail Client
run: sudo apt-get update && sudo apt-get install -y msmtp
- name: Configure msmtp
run: |
echo "defaults" > ~/.msmtprc
echo "auth on" >> ~/.msmtprc
echo "tls on" >> ~/.msmtprc
echo "tls_starttls on" >> ~/.msmtprc
echo "account default" >> ~/.msmtprc
echo "host ${{ vars.SMTP_HOST }}" >> ~/.msmtprc
echo "port ${{ vars.SMTP_PORT }}" >> ~/.msmtprc
echo "user ${{ vars.SMTP_USER }}" >> ~/.msmtprc
echo "password ${{ vars.SMTP_PASSWORD }}" >> ~/.msmtprc
echo "from ${{ vars.SMTP_SENDER }}" >> ~/.msmtprc
chmod 600 ~/.msmtprc
- name: Create Email
run: |
REPOSITORY_NAME=$(basename ${{ env.GITHUB_REPOSITORY }})
echo "Subject: Neues Release [$REPOSITORY_NAME]" > email.html
echo "From: ${{ vars.SMTP_SENDER }}" >> email.html
echo "To: ${{ vars.SMTP_QA_RECIPIENT }}" >> email.html
echo "Content-Type: text/html; charset=UTF-8" >> email.html
echo "" >> email.html
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD Html 4.01 Transitional//EN\">" >> email.html
echo "<html>" >> email.html
echo "<body>" >> email.html
echo "<h1>Das <a href=\"https://gitea.greyhound-software.com/${{ env.GITHUB_REPOSITORY }}/releases/tag/${{ inputs.tag }}\">Release</a> für <a href=\"https://gitea.greyhound-software.com/${{ env.GITHUB_REPOSITORY }}\">$REPOSITORY_NAME</a> wurde befördert.</h1>" >> email.html
echo "<p><strong>${{ inputs.oldChannel }} >> ${{ inputs.newChannel }}</strong></p>" >> email.html
echo "</body>" >> email.html
echo "</html>" >> email.html
- name: Send Email
run: |
msmtp --debug ${{ vars.SMTP_QA_RECIPIENT }} < email.html

View File

@ -75,7 +75,7 @@ jobs:
release_create=$(curl -s -X POST -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"tag_name\": \"${{ inputs.tag }}\", \"prerelease\": $prerelease}" \
-d "{\"body\": \"Kanal: ${{ inputs.buildChannel }} \n\n$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"tag_name\": \"${{ inputs.tag }}\", \"prerelease\": $prerelease}" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases")
echo "Release created: $release_create"
@ -87,7 +87,7 @@ jobs:
release_update=$(curl -s -X PATCH -H "Authorization: token $API_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"body\": \"$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"prerelease\": $prerelease}" \
-d "{\"body\": \"Kanal: ${{ inputs.buildChannel }} \n\n$milestoneUrl \n${{ inputs.downloadUrl }}\", \"name\": \"${{ inputs.milestoneName }}\", \"prerelease\": $prerelease}" \
"$GITEA_API_URL/repos/$OWNER/${{ inputs.repo }}/releases/$release_id")
echo "Release updated: $release_update"