From 642480e6dcdf50b3251e6e1e129dedee100a29ca Mon Sep 17 00:00:00 2001 From: Marco Maatz Date: Tue, 20 May 2025 09:09:10 +0200 Subject: [PATCH] asd --- .gitea/workflows/getReleaseChannel.yaml | 37 +++++++++++++++++ .gitea/workflows/sendPromoteMail.yaml | 54 +++++++++++++++++++++++++ .gitea/workflows/updateRelease.yaml | 4 +- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/getReleaseChannel.yaml create mode 100644 .gitea/workflows/sendPromoteMail.yaml diff --git a/.gitea/workflows/getReleaseChannel.yaml b/.gitea/workflows/getReleaseChannel.yaml new file mode 100644 index 0000000..4c7d903 --- /dev/null +++ b/.gitea/workflows/getReleaseChannel.yaml @@ -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 \ No newline at end of file diff --git a/.gitea/workflows/sendPromoteMail.yaml b/.gitea/workflows/sendPromoteMail.yaml new file mode 100644 index 0000000..8b92284 --- /dev/null +++ b/.gitea/workflows/sendPromoteMail.yaml @@ -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 "" >> email.html + echo "" >> email.html + echo "" >> email.html + echo "

Das Release für $REPOSITORY_NAME wurde befördert.

" >> email.html + echo "

${{ inputs.oldChannel }} >> ${{ inputs.newChannel }}

" >> email.html + echo "" >> email.html + echo "" >> email.html + - name: Send Email + run: | + msmtp --debug ${{ vars.SMTP_QA_RECIPIENT }} < email.html diff --git a/.gitea/workflows/updateRelease.yaml b/.gitea/workflows/updateRelease.yaml index 3f40234..6764554 100644 --- a/.gitea/workflows/updateRelease.yaml +++ b/.gitea/workflows/updateRelease.yaml @@ -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"