Skip to content

Commit 9a60272

Browse files
authored
Update work-jar.yml
1 parent a980ab6 commit 9a60272

1 file changed

Lines changed: 35 additions & 19 deletions

File tree

.github/workflows/work-jar.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ on:
44
branches:
55
- main
66
- feature/hook
7-
87
permissions:
98
contents: write
109
pages: write
1110
id-token: write
12-
1311
jobs:
1412
publish-jar:
1513
runs-on: ubuntu-latest
@@ -19,60 +17,78 @@ jobs:
1917
with:
2018
token: ${{ secrets.GITHUB_TOKEN }}
2119
fetch-depth: 0
22-
2320
- name: Set up JDK 17
2421
uses: actions/setup-java@v4
2522
with:
2623
java-version: '17'
2724
distribution: 'temurin'
28-
2925
- name: Grant execute permission for gradlew
3026
run: chmod +x gradlew
31-
3227
- name: Extract version from build.gradle.kts
3328
id: extract_version
3429
run: |
3530
VERSION=$(./gradlew -q printVersion)
3631
echo "version=$VERSION" >> $GITHUB_OUTPUT
3732
echo "Extracted version: $VERSION"
38-
3933
- name: Check if tag already exists
4034
id: check_tag
4135
run: |
4236
if git tag -l "${{ steps.extract_version.outputs.version }}" | grep -q "${{ steps.extract_version.outputs.version }}"; then
4337
echo "tag_exists=true" >> $GITHUB_OUTPUT
44-
echo "Tag ${{ steps.extract_version.outputs.version }} already exists"
38+
echo "Tag ${{ steps.extract_version.outputs.version }} already exists and will be overwritten"
4539
else
4640
echo "tag_exists=false" >> $GITHUB_OUTPUT
4741
echo "Tag ${{ steps.extract_version.outputs.version }} does not exist"
4842
fi
49-
5043
- name: Publish Maven artifacts to local repo
5144
run: ./gradlew publish
5245
env:
5346
GROUP_ID: fr.sandro642.github
5447
ARTIFACT_ID: ConnectorAPI
5548
VERSION: ${{ steps.extract_version.outputs.version }}
56-
57-
- name: Deploy to GitHub Pages
58-
uses: JamesIves/github-pages-deploy-action@v4
49+
- name: Checkout target repository
50+
uses: actions/checkout@v4
5951
with:
52+
repository: sandro642/sandro642.github.io
6053
token: ${{ secrets.GH_TOKEN }}
61-
repository-name: sandro642/sandro642.github.io
62-
branch: main
63-
folder: build/repo
64-
target-folder: connectorapi/jar
65-
66-
- name: Create and push Git tag
67-
if: steps.check_tag.outputs.tag_exists == 'false'
54+
path: target-repo
55+
- name: Clean existing version folder
56+
run: |
57+
if [ -d "target-repo/connectorapi/jar" ]; then
58+
echo "Cleaning existing connectorapi/jar folder..."
59+
rm -rf target-repo/connectorapi/jar
60+
fi
61+
mkdir -p target-repo/connectorapi/jar
62+
- name: Copy new artifacts
63+
run: |
64+
cp -r build/repo/* target-repo/connectorapi/jar/
65+
- name: Deploy to GitHub Pages
66+
run: |
67+
cd target-repo
68+
git config --local user.email "action@github.com"
69+
git config --local user.name "GitHub Action"
70+
git add .
71+
if git diff --staged --quiet; then
72+
echo "No changes to commit"
73+
else
74+
git commit -m "Update ConnectorAPI artifacts for version ${{ steps.extract_version.outputs.version }}"
75+
git push
76+
fi
77+
- name: Create and push Git tag (with override)
6878
run: |
6979
git config --local user.email "action@github.com"
7080
git config --local user.name "GitHub Action"
7181
7282
# S'assurer qu'on pousse vers le bon repository
7383
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
7484
75-
# Créer et pousser le tag
85+
# Supprimer le tag localement s'il existe
86+
git tag -d "${{ steps.extract_version.outputs.version }}" || true
87+
88+
# Supprimer le tag distant s'il existe
89+
git push origin --delete "${{ steps.extract_version.outputs.version }}" || true
90+
91+
# Créer et pousser le nouveau tag
7692
git tag -a "${{ steps.extract_version.outputs.version }}" -m "Release version ${{ steps.extract_version.outputs.version }}"
7793
git push origin "${{ steps.extract_version.outputs.version }}"
7894
env:

0 commit comments

Comments
 (0)