Plex-Meta-Manager/.github/workflows/release-develop.yml

121 lines
4.4 KiB
YAML
Raw Permalink Normal View History

2024-05-31 13:59:14 +00:00
name: Develop Release
2024-05-28 20:59:00 +00:00
on:
workflow_dispatch:
inputs:
build_number:
description: Choose the build number to push develop to.
default: 0
2024-05-28 20:59:00 +00:00
jobs:
2024-05-31 13:59:14 +00:00
release-develop:
2024-05-28 20:59:00 +00:00
runs-on: ubuntu-latest
steps:
- name: Create App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_TOKEN }}
- name: Check Out Repo
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
2024-05-30 20:59:29 +00:00
ref: develop
2024-05-28 20:59:00 +00:00
fetch-depth: 0
2024-05-30 20:59:29 +00:00
- name: Fast Forward Develop
id: forward
2024-05-28 20:59:00 +00:00
run: |
2024-05-30 20:59:29 +00:00
value=$(cat VERSION)
develop_hash=$(git rev-parse HEAD)
if [[ "$value" == *"-"* ]]; then
develop_build="$((${value#*-build}))"
else
develop_build="0"
fi
git checkout origin/nightly
value=$(cat VERSION)
if [[ "$value" == *"-"* ]]; then
nightly_build="$((${value#*-build}))"
else
nightly_build="0"
fi
echo "DEVELOP_BUILD: '${develop_build}'"
echo "NIGHTLY_BUILD: '${nightly_build}'"
if ! [[ ${{ github.event.inputs.build_number }} =~ ^[0-9]+$ ]]; then
echo "::error::BUILD_NUMBER (${{ github.event.inputs.build_number }}) must be a number"
2024-05-30 20:59:29 +00:00
exit 1
elif [[ "${{ github.event.inputs.build_number }}" == "0" ]]; then
next_build="${nightly_build}"
elif (( ${{ github.event.inputs.build_number }} <= develop_build )); then
echo "::error::BUILD_NUMBER (${{ github.event.inputs.build_number }}) must be greater than DEVELOP_BUILD (${develop_build})"
2024-05-30 20:59:29 +00:00
exit 1
elif (( ${{ github.event.inputs.build_number }} > nightly_build )); then
echo "::error::BUILD_NUMBER (${{ github.event.inputs.build_number }}) must be less than or equal to NIGHTLY_BUILD (${nightly_build})"
exit 1
else
next_build="${{ github.event.inputs.build_number }}"
2024-05-30 20:59:29 +00:00
fi
echo "NEXT_BUILD: '${next_build}'"
echo "build=next_build" >> $GITHUB_OUTPUT
2024-05-30 20:59:29 +00:00
while : ; do
value=$(cat VERSION)
if [[ "$value" == *"-"* ]]; then
loop_build="$((${value#*-build}))"
else
loop_build="1"
fi
if [[ "$next_build" == "$loop_build" ]]; then
hash=$(git rev-parse HEAD)
echo "Fast Forwarding Develop to ${hash}"
git push origin ${hash}:refs/heads/develop
break
fi
git checkout HEAD^
hash=$(git rev-parse HEAD)
if [[ "$develop_hash" == "$hash" ]]; then
echo "::error::No Commit found to Fast Forward"
exit 1
fi
done
2024-05-31 13:59:14 +00:00
- name: Discord Success Notification
uses: Kometa-Team/discord-notifications@master
if: success()
with:
webhook_id_token: ${{ secrets.BUILD_WEBHOOK }}
title: "${{ vars.REPO_NAME }} develop pushed to Build ${{ steps.forward.outputs.build }}: ${{ vars.TEXT_SUCCESS }}"
2024-05-31 13:59:14 +00:00
url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }}
color: ${{ vars.COLOR_SUCCESS }}
username: ${{ vars.BOT_NAME }}
avatar_url: ${{ vars.BOT_IMAGE }}
author: ${{ vars.GIT_NAME }}
author_icon_url: ${{ vars.GIT_IMAGE }}
- name: Discord Failure Notification
uses: Kometa-Team/discord-notifications@master
if: failure()
with:
webhook_id_token: ${{ secrets.BUILD_WEBHOOK }}
message: ${{ vars.BUILD_FAILURE_ROLE }}
title: "${{ vars.REPO_NAME }} develop pushed to Build ${{ steps.forward.outputs.build }}: ${{ vars.TEXT_FAILURE }}"
2024-05-31 13:59:14 +00:00
url: https://github.com/Kometa-Team/${{ vars.REPO_NAME }}/actions/runs/${{ github.run_id }}
color: ${{ vars.COLOR_FAILURE }}
username: ${{ vars.BOT_NAME }}
avatar_url: ${{ vars.BOT_IMAGE }}
author: ${{ vars.GIT_NAME }}
author_icon_url: ${{ vars.GIT_IMAGE }}