|
| 1 | +name: "security-proxy" |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + pull_request: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + if: "!startsWith(github.event.head_commit.message, '[skip ci] ')" |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 10 |
| 15 | + steps: |
| 16 | + - name: "Checking out" |
| 17 | + uses: actions/checkout@v5 |
| 18 | + |
| 19 | + - name: "Setting up Java" |
| 20 | + uses: actions/setup-java@v5 |
| 21 | + with: |
| 22 | + java-version: '11' |
| 23 | + distribution: 'adopt' |
| 24 | + cache: 'maven' |
| 25 | + server-id: geOrchestra-artifactory |
| 26 | + server-username: ARTIFACTORY_USERNAME_REF |
| 27 | + server-password: ARTIFACTORY_TOKEN_REF |
| 28 | + |
| 29 | + - name: "Installing & checking formatting" |
| 30 | + run: mvn install -DskipTests --no-transfer-progress -B -Dfmt.action=validate -Dadditionalparam=-Xdoclint:none |
| 31 | + # note "-pl :security-proxy --also-make" builds only the project and its dependencies |
| 32 | + |
| 33 | + - name: "Running tests" |
| 34 | + run: mvn verify -Pit --no-transfer-progress -Dfmt.skip=true -Dadditionalparam=-Xdoclint:none |
| 35 | + |
| 36 | + - name: Getting image tag |
| 37 | + if: github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' |
| 38 | + id: version |
| 39 | + run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT |
| 40 | + |
| 41 | + - name: "Building docker image" |
| 42 | + if: github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' |
| 43 | + run: mvn clean package docker:build -Pdocker,log4j-logstash,sentry-log4j -DdockerImageName=georchestra/security-proxy:${{ steps.version.outputs.VERSION }} -DskipTests --no-transfer-progress |
| 44 | + |
| 45 | + - name: "Logging in docker.io" |
| 46 | + uses: azure/docker-login@v2 |
| 47 | + if: github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 48 | + with: |
| 49 | + username: '${{ secrets.DOCKER_HUB_USERNAME }}' |
| 50 | + password: '${{ secrets.DOCKER_HUB_PASSWORD }}' |
| 51 | + |
| 52 | + - name: "Update Docker Hub Description" |
| 53 | + if: github.ref == 'refs/heads/master' && github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 54 | + uses: peter-evans/dockerhub-description@v4 |
| 55 | + with: |
| 56 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 57 | + password: ${{ secrets.DOCKER_HUB_PASSWORD }} |
| 58 | + repository: georchestra/security-proxy |
| 59 | + readme-filepath: ./security-proxy/DOCKER_HUB.md |
| 60 | + short-description: 'Security-proxy module for the geOrchestra SDI' |
| 61 | + |
| 62 | + - name: "Pushing latest to docker.io" |
| 63 | + if: github.ref == 'refs/heads/master' && github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 64 | + run: | |
| 65 | + docker tag georchestra/security-proxy:${{ steps.version.outputs.VERSION }} georchestra/security-proxy:latest |
| 66 | + docker push georchestra/security-proxy:latest |
| 67 | +
|
| 68 | + - name: "Pushing release branch or tag to docker.io" |
| 69 | + if: (endsWith(github.ref, '.x') || contains(github.ref, 'refs/tags/')) && github.repository == 'georchestra/security-proxy' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 70 | + run: | |
| 71 | + docker push georchestra/security-proxy:${{ steps.version.outputs.VERSION }} |
| 72 | +
|
| 73 | + - name: "Publish war in artifactory" |
| 74 | + run: mvn deploy -DskipTests |
| 75 | + if: github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 76 | + continue-on-error: true |
| 77 | + env: |
| 78 | + ARTIFACTORY_TOKEN_REF: ${{ secrets.ARTIFACTORY_TOKEN }} |
| 79 | + ARTIFACTORY_USERNAME_REF: ${{ secrets.ARTIFACTORY_USERNAME }} |
| 80 | + |
| 81 | + - name: "Remove SNAPSHOT jars from repository" |
| 82 | + if: github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' |
| 83 | + run: | |
| 84 | + find .m2/repository -name "*SNAPSHOT*" -type d | xargs rm -rf {} |
0 commit comments