Compare commits
4 Commits
bugix/pipe
...
fe45d901e4
Author | SHA1 | Date | |
---|---|---|---|
fe45d901e4 | |||
5867cfc3e1 | |||
2be4331a6e | |||
9ee2750534 |
@@ -2,22 +2,25 @@ name: Gitea CI/CD
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
#push:
|
||||||
branches: [ "development", "main", "staging" ]
|
#branches: [ "development", "main", "staging"]
|
||||||
|
#tags: [ "v*.*.*" ]
|
||||||
|
pull_request:
|
||||||
|
#branches: [ "development", "main", "staging" ]
|
||||||
tags: [ "v*.*.*" ]
|
tags: [ "v*.*.*" ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOTNET_VERSION: '8.0.x'
|
DOTNET_VERSION: '8.0.x'
|
||||||
DOCKER_IMAGE_NAME: watcher
|
DOCKER_IMAGE_NAME: watcher-server
|
||||||
REGISTRY_URL: git.triggermeelmo.com
|
REGISTRY_URL: git.triggermeelmo.com
|
||||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
dotnet-build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -43,14 +46,13 @@ jobs:
|
|||||||
|
|
||||||
set-tag:
|
set-tag:
|
||||||
name: Set Tag Name
|
name: Set Tag Name
|
||||||
needs: [dotnet-build-and-test]
|
|
||||||
#if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||||
should_tag: ${{ steps.set_tag.outputs.should_tag }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Determine next semantic version tag
|
- name: Determine next semantic version tag
|
||||||
id: set_tag
|
id: set_tag
|
||||||
@@ -72,33 +74,20 @@ jobs:
|
|||||||
major=$((major + 1))
|
major=$((major + 1))
|
||||||
minor=0
|
minor=0
|
||||||
patch=0
|
patch=0
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new major version tag: ${new_tag}"
|
|
||||||
|
|
||||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||||
minor=$((minor + 1))
|
minor=$((minor + 1))
|
||||||
patch=0
|
patch=0
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new minor version tag: ${new_tag}"
|
|
||||||
|
|
||||||
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
||||||
patch=$((patch + 1))
|
patch=$((patch + 1))
|
||||||
new_tag="v${major}.${minor}.${patch}"
|
|
||||||
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
|
||||||
echo "should_tag=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Creating new patch version tag: ${new_tag}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
new_tag="v${major}.${minor}.${patch}"
|
||||||
|
echo "Creating new version tag: ${new_tag}"
|
||||||
|
echo "tag_name=${new_tag}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
docker-build-and-push:
|
docker-build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [dotnet-build-and-test, set-tag]
|
needs: [build-and-test, set-tag]
|
||||||
if: |
|
|
||||||
needs.set-tag.outputs.should_tag == 'true' &&
|
|
||||||
github.event_name != 'pull_request'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -128,16 +117,31 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Git user
|
- name: Check if tag already exists
|
||||||
|
id: check_tag
|
||||||
run: |
|
run: |
|
||||||
git config user.name "GitHub Actions"
|
git fetch --tags
|
||||||
git config user.email "actions@github.com"
|
if git rev-parse "${{ needs.set-tag.outputs.tag_name }}" >/dev/null 2>&1; then
|
||||||
|
echo "Tag ${{ needs.set-tag.outputs.tag_name }} already exists!"
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Tag ${{ needs.set-tag.outputs.tag_name }} does not exist"
|
||||||
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create and push tag
|
- name: Create and push tag
|
||||||
env:
|
if: steps.check_tag.outputs.exists == 'false'
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
echo "Creating new tag: ${{ needs.set-tag.outputs.tag_name }}"
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
git tag ${{ needs.set-tag.outputs.tag_name }}
|
git tag ${{ needs.set-tag.outputs.tag_name }}
|
||||||
git push origin ${{ needs.set-tag.outputs.tag_name }}
|
git push -u origin ${{ needs.set-tag.outputs.tag_name }}
|
||||||
|
echo "Tag created and pushed successfully"
|
||||||
|
|
||||||
|
- name: Skip tag creation
|
||||||
|
if: steps.check_tag.outputs.exists == 'true'
|
||||||
|
run: |
|
||||||
|
echo "Skipping tag creation - ${{ needs.set-tag.outputs.tag_name }} already exists"
|
Reference in New Issue
Block a user