Compare commits
17 Commits
v0.1.3
...
fe45d901e4
Author | SHA1 | Date | |
---|---|---|---|
fe45d901e4 | |||
ba6e201adc | |||
5867cfc3e1 | |||
8771e1ee02 | |||
2be4331a6e | |||
98754be109 | |||
9ee2750534 | |||
9920c94a8b | |||
b7bc477d2e | |||
ab11665665 | |||
37468b6785 | |||
471767c4ed | |||
596baba5ef | |||
12390031f9 | |||
daed8c1462 | |||
7e5e295590 | |||
cb91ca3159 |
@@ -2,24 +2,26 @@ name: Gitea CI/CD
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "development", "main", "staging"]
|
||||
tags: [ "v*.*.*" ]
|
||||
#push:
|
||||
#branches: [ "development", "main", "staging"]
|
||||
#tags: [ "v*.*.*" ]
|
||||
pull_request:
|
||||
branches: [ "development", "main", "staging" ]
|
||||
#branches: [ "development", "main", "staging" ]
|
||||
tags: [ "v*.*.*" ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
env:
|
||||
DOTNET_VERSION: '8.0.x'
|
||||
DOCKER_IMAGE_NAME: watcher-server
|
||||
REGISTRY_URL: git.triggermeelmo.com
|
||||
DOCKER_PLATFORMS: 'linux/amd64,linux/arm64'
|
||||
TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/development' && 'development' || github.ref_type == 'tag' && github.ref_name || 'pr' }}
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -45,12 +47,12 @@ jobs:
|
||||
set-tag:
|
||||
name: Set Tag Name
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
outputs:
|
||||
tag_name: ${{ steps.set_tag.outputs.tag_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine next semantic version tag
|
||||
id: set_tag
|
||||
@@ -75,17 +77,16 @@ jobs:
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
else
|
||||
elif [[ "${GITHUB_REF}" == "refs/heads/staging" ]]; then
|
||||
patch=$((patch + 1))
|
||||
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:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
|
||||
needs: [build-and-test, set-tag]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -112,21 +113,35 @@ jobs:
|
||||
name: Create Tag
|
||||
needs: [docker-build-and-push]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Git user
|
||||
- name: Check if tag already exists
|
||||
id: check_tag
|
||||
run: |
|
||||
git config user.name "GitHub Actions"
|
||||
git config user.email "actions@github.com"
|
||||
git fetch --tags
|
||||
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
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: steps.check_tag.outputs.exists == 'false'
|
||||
run: |
|
||||
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 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