Release v1.0.50
Some checks failed
Conditional Release Build / read-conditions (push) Successful in 8s
Conditional Release Build / create-docker-image (push) Has been cancelled
Conditional Release Build / update-to-release-branch (push) Has been cancelled
Conditional Release Build / create-release (push) Has been cancelled
Some checks failed
Conditional Release Build / read-conditions (push) Successful in 8s
Conditional Release Build / create-docker-image (push) Has been cancelled
Conditional Release Build / update-to-release-branch (push) Has been cancelled
Conditional Release Build / create-release (push) Has been cancelled
This commit is contained in:
@@ -1,27 +1,82 @@
|
||||
name: Release Build
|
||||
name: Conditional Release Build
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
create-release:
|
||||
read-conditions:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
# image: golang:1.21
|
||||
# image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:builder-1.0.32
|
||||
image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:latest
|
||||
outputs:
|
||||
create-release: ${{ steps.parse-conditions.outputs.create-release }}
|
||||
create-docker-image: ${{ steps.parse-conditions.outputs.create-docker-image }}
|
||||
update-to-release-branch: ${{ steps.parse-conditions.outputs.update-to-release-branch }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
run: |
|
||||
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
|
||||
cd hello_gitea
|
||||
git checkout ${{ github.ref }}
|
||||
git checkout ${{ github.ref }}
|
||||
|
||||
- name: Parse build conditions
|
||||
id: parse-conditions
|
||||
run: |
|
||||
cd hello_gitea
|
||||
|
||||
# Default values if file doesn't exist
|
||||
CREATE_RELEASE="1"
|
||||
CREATE_DOCKER_IMAGE="1"
|
||||
UPDATE_TO_RELEASE_BRANCH="1"
|
||||
|
||||
# Read conditions from file if it exists
|
||||
if [ -f .build.conditions ]; then
|
||||
echo "Reading .build.conditions file..."
|
||||
while IFS=':' read -r job condition; do
|
||||
# Remove leading/trailing whitespace
|
||||
job=$(echo "$job" | xargs)
|
||||
condition=$(echo "$condition" | xargs)
|
||||
|
||||
case "$job" in
|
||||
"create-release")
|
||||
CREATE_RELEASE="$condition"
|
||||
;;
|
||||
"create-docker-image")
|
||||
CREATE_DOCKER_IMAGE="$condition"
|
||||
;;
|
||||
"update-to-release-branch")
|
||||
UPDATE_TO_RELEASE_BRANCH="$condition"
|
||||
;;
|
||||
esac
|
||||
done < .build.conditions
|
||||
|
||||
echo "Parsed conditions:"
|
||||
echo " create-release: $CREATE_RELEASE"
|
||||
echo " create-docker-image: $CREATE_DOCKER_IMAGE"
|
||||
echo " update-to-release-branch: $UPDATE_TO_RELEASE_BRANCH"
|
||||
else
|
||||
echo "No .build.conditions file found, using defaults"
|
||||
fi
|
||||
|
||||
# Set outputs
|
||||
echo "create-release=$CREATE_RELEASE" >> $GITHUB_OUTPUT
|
||||
echo "create-docker-image=$CREATE_DOCKER_IMAGE" >> $GITHUB_OUTPUT
|
||||
echo "update-to-release-branch=$UPDATE_TO_RELEASE_BRANCH" >> $GITHUB_OUTPUT
|
||||
|
||||
create-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: read-conditions
|
||||
if: needs.read-conditions.outputs.create-release == '1'
|
||||
container:
|
||||
image: ${{ secrets.DOCKERHUB_USERNAME }}/my-build-golang-runner:latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
run: |
|
||||
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
|
||||
cd hello_gitea
|
||||
git checkout ${{ github.ref }}
|
||||
|
||||
- name: Setup Go
|
||||
run: |
|
||||
# Install jq for JSON parsing
|
||||
# apt-get update && apt-get install -y jq
|
||||
git --version
|
||||
go version
|
||||
jq --version
|
||||
@@ -29,6 +84,13 @@ jobs:
|
||||
- name: Build all binaries
|
||||
run: |
|
||||
cd hello_gitea
|
||||
|
||||
# Проверяем, изменились ли зависимости
|
||||
if [ ! -f go.sum ] || ! go mod verify >/dev/null 2>&1; then
|
||||
echo "Dependencies changed, downloading..."
|
||||
go mod download
|
||||
fi
|
||||
|
||||
mkdir -p bin
|
||||
echo "Building for all platforms..."
|
||||
|
||||
@@ -99,13 +161,13 @@ jobs:
|
||||
|
||||
create-docker-image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [read-conditions, create-release]
|
||||
if: needs.read-conditions.outputs.create-docker-image == '1' && (needs.create-release.result == 'success' || needs.create-release.result == 'skipped')
|
||||
container:
|
||||
image: docker:28.3.2-dind
|
||||
needs: create-release
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
run: |
|
||||
# Install git
|
||||
apk add --no-cache git
|
||||
|
||||
echo "=== GitHub Variables ==="
|
||||
@@ -151,49 +213,26 @@ jobs:
|
||||
|
||||
update-to-release-branch:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [read-conditions, create-docker-image]
|
||||
if: needs.read-conditions.outputs.update-to-release-branch == '1' && (needs.create-docker-image.result == 'success' || needs.create-docker-image.result == 'skipped')
|
||||
container:
|
||||
image: docker:28.3.2-dind
|
||||
needs: create-docker-image
|
||||
steps:
|
||||
- name: Create Release Branch
|
||||
run: |
|
||||
echo "Creating release branch..."
|
||||
echo "=== GitHub Variables ==="
|
||||
echo "github.ref = ${{ github.ref }}"
|
||||
echo "github.ref_name = ${{ github.ref_name }}"
|
||||
echo "github.sha = ${{ github.sha }}"
|
||||
echo "github.repository = ${{ github.repository }}"
|
||||
echo "DOCKERHUB_USERNAME = ${{ secrets.DOCKERHUB_USERNAME }}"
|
||||
echo "DOCKERHUB_TOKEN = ${{ secrets.DOCKERHUB_TOKEN }}"
|
||||
echo "GITEATOKEN = ${{ secrets.GITEATOKEN }}"
|
||||
echo "========================"
|
||||
# Clone repository
|
||||
echo "Cloning repository..."
|
||||
apk add --no-cache git
|
||||
git clone https://oauth2:${{ secrets.GITEATOKEN }}@direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git hello_gitea
|
||||
cd hello_gitea
|
||||
|
||||
# Configure git
|
||||
echo "Configuring git..."
|
||||
git config user.email "info@direct-dev.ru"
|
||||
git config user.name "Direct-Dev-Robot"
|
||||
|
||||
# Check if release branch exists
|
||||
echo "Checking if release branch exists..."
|
||||
if git ls-remote --heads origin release | grep -q release; then
|
||||
echo "Release branch exists, checking out..."
|
||||
git checkout release
|
||||
echo "release branch exists - pulling release branch..."
|
||||
git pull origin release
|
||||
else
|
||||
echo "release branch does not exist - creating new release branch..."
|
||||
git checkout -b release
|
||||
fi
|
||||
|
||||
# Reset to the tag commit
|
||||
echo "Resetting to the tag commit ${{ github.ref_name }} ..."
|
||||
git reset --hard ${{ github.ref_name }}
|
||||
|
||||
# Push changes to release branch
|
||||
echo "Pushing changes to release branch..."
|
||||
git push origin release --force
|
||||
echo "Changes pushed to release branch successfully"
|
||||
git push origin release --force
|
Reference in New Issue
Block a user