Skip to content

Commit

Permalink
premier service qui renvoie juste le tef
Browse files Browse the repository at this point in the history
  • Loading branch information
julg committed Feb 16, 2024
1 parent 43b1561 commit 97e01b5
Show file tree
Hide file tree
Showing 14 changed files with 1,071 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build-test-pubtodockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: "build-test-pubtodockerhub"

# IMPORTANT : personnalisez cette variable pour que les images
# de votre application soient pousées sur dockerhub
# dans l'organisation/image docker ayant ce nom
# exemple, si vous indiquez : abesesr/abes-hello
# alors l'image sera poussée sur https://hub.docker.com/r/abesesr/abes-hello
env:
DOCKERHUB_IMAGE_PREFIX: abesesr/theses

on:
push:
paths-ignore:
- '**.md'
- '.github/**'
- '.properties'
workflow_dispatch:


jobs:
build-test-pubtodockerhub:
runs-on: ubuntu-latest
steps:


- name: "Build: checkout source code"
uses: actions/checkout@v2
- name: "Build: build docker image"
run: |
docker build . -t localimage:latest
- name: "Push: prepare version from git tags/branchs"
id: docker_tag_meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKERHUB_IMAGE_PREFIX }}
- name: "Push: login to DockerHub"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: "Push: push docker image"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
run: |
DOCKER_TAGS="${{ steps.docker_tag_meta.outputs.tags }}"
for DOCKER_TAG in $DOCKER_TAGS
do
# publication de l'image docker
docker build . --target api-export-image -t ${DOCKER_TAG}-api-export
docker push ${DOCKER_TAG}-api-export
done
80 changes: 80 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: 'Create release'

on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Version de la release (semver)'
required: true
default: 'x.x.x'

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v3'
with:
fetch-depth: '0' # to get all the tags locally
# https://stackoverflow.com/questions/67550727/push-event-doesnt-trigger-workflow-on-push-paths-github-actions
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}


- name: 'Verify release is created only on "main" or "master" git branch'
run: |
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo $CURRENT_GIT_BRANCH
[[ "$CURRENT_GIT_BRANCH" == "main" || "$CURRENT_GIT_BRANCH" == "master" ]] && exit 0 || exit 1
- name: 'Verify version is semver formatted (X.X.X)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
run: |
echo $NEW_TAG | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'
- name: 'Verify version is not already used as a git tag'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
run: |
[[ "$(git tag --list | grep $NEW_TAG)" == "" ]] && exit 0 || exit 1
- name: 'Generate the new version (patch few files + git tag)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}
run: |
# préparation de la release qui va :
# - modifier le numéro de version dans les pom.xml du projet
# - créer un tag git du numéro de version en question
# - pousser le tout sur le dépôt github et faire la fusion avec la branche develop
git config --global user.email "github-action@noreply"
git config --global user.name "Github Action"
# patch la version dans les pom.xml avec xmllint
sudo apt-get install -y libxml2-utils
echo -e "setns x=http://maven.apache.org/POM/4.0.0\ncd /x:project/x:version\nset $NEW_TAG\nsave" \
| xmllint --shell ./pom.xml
for POM_FILE in $(ls */pom.xml)
do
echo -e "setns x=http://maven.apache.org/POM/4.0.0\ncd /x:project/x:parent/x:version\nset $NEW_TAG\nsave" \
| xmllint --shell $POM_FILE
done
# création du tag
git add .
git commit -m "Version $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
git commit --amend -m "Version $NEW_TAG [skip ci]"
git push
# merge la préparation de la nouvelle version sur develop
git switch develop
git merge main -m "Merge main to develop [skip ci]"
git push
- name: 'Create the github release'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.releaseVersion }}
generate_release_notes: true
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
.mvn

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
**/src/main/**/*.properties
**/src/test/**/*.properties
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###
# Image pour la compilation
FROM maven:3-eclipse-temurin-11 as build-image
WORKDIR /build/
# Installation et configuration de la locale FR
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y install locales
RUN sed -i '/fr_FR.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:fr
ENV LC_ALL fr_FR.UTF-8


# On lance la compilation Java
# On débute par une mise en cache docker des dépendances Java
# cf https://www.baeldung.com/ops/docker-cache-maven-dependencies
COPY ./pom.xml /build/pom.xml
RUN mvn verify --fail-never
# et la compilation du code Java
COPY ./src/ /build/src/
RUN mvn --batch-mode -e \
-Dmaven.test.skip=false \
-Duser.timezone=Europe/Paris \
-Duser.language=fr \
package


###
# Image pour le module theses-export

FROM eclipse-temurin:11-jre as api-export-image
WORKDIR /app/
COPY --from=build-image /build/target/*.jar /app/theses-api-export.jar
ENTRYPOINT exec java $JAVA_OPTS -jar /app/theses-api-export.jar
Loading

0 comments on commit 97e01b5

Please sign in to comment.