|
| 1 | +name: Maven Build and Deploy to AWS CodeArtifact |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 4.2.3.P1_Actions |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + MVN_OPTS: "-P github --file ./pom.xml -DskipTests --batch-mode" |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | +# runs-on: self-hosted |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + id-token: write |
| 18 | + contents: read |
| 19 | + steps: |
| 20 | + # Checkout the code |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + fetch-depth: 0 # Fetch all history for tags and branches |
| 25 | + |
| 26 | +# - name: Set up Maven |
| 27 | +# uses: stCarolas/setup-maven@v4 |
| 28 | +# with: |
| 29 | +# maven-version: '3.9.6' |
| 30 | + |
| 31 | + |
| 32 | + # Configure AWS credentials |
| 33 | + - name: Configure AWS Credentials |
| 34 | + uses: aws-actions/configure-aws-credentials@v4 |
| 35 | + with: |
| 36 | + role-to-assume: arn:aws:iam::851725588390:role/gh-deploy-protostream |
| 37 | + aws-region: "eu-west-1" |
| 38 | + |
| 39 | + - name: Login to CodeArtifact |
| 40 | + id: codeartifact |
| 41 | + run: | |
| 42 | + token=$(aws codeartifact get-authorization-token --domain inpart --domain-owner 851725588390 --query authorizationToken --output text) |
| 43 | + url=$(aws codeartifact get-repository-endpoint --domain inpart --domain-owner 851725588390 --repository inpart-maven-releases --format maven --query repositoryEndpoint --output text) |
| 44 | + # Ensure URL ends with a trailing slash |
| 45 | + [[ "$url" != */ ]] && url="${url}/" |
| 46 | + echo "repo_token=$token" >> $GITHUB_OUTPUT |
| 47 | + echo "repo_url=$url" >> $GITHUB_OUTPUT |
| 48 | + echo "Using repository URL: $url" |
| 49 | +
|
| 50 | + - name: Set up JDK and Maven settings |
| 51 | + uses: actions/setup-java@v4 |
| 52 | + with: |
| 53 | + java-version: '8' |
| 54 | + distribution: 'temurin' |
| 55 | + overwrite-settings: true |
| 56 | + cache: 'maven' |
| 57 | + server-id: inpart-maven-releases |
| 58 | + server-username: MAVEN_DEPLOY_USERNAME |
| 59 | + server-password: MAVEN_DEPLOY_PASSWORD |
| 60 | + |
| 61 | + - name: Debug Maven Settings and Credentials |
| 62 | + run: | |
| 63 | + echo "Repository URL: ${{ steps.codeartifact.outputs.repo_url }}" |
| 64 | + echo "Token available: ${{ steps.codeartifact.outputs.repo_token != '' }}" |
| 65 | + mvn help:effective-settings |
| 66 | +
|
| 67 | +# - name: Set Release Version |
| 68 | +# run: | |
| 69 | +# # Get the latest tag by creation date |
| 70 | +# git fetch --tags |
| 71 | +# LATEST_TAG=$(git tag --sort=-creatordate | head -n 1) |
| 72 | +# VERSION=${LATEST_TAG:1} # Remove the 'v' prefix |
| 73 | +# echo "Setting version to $VERSION" |
| 74 | +# mvn -DprocessAllModules -DnewVersion=$VERSION -DgenerateBackupPoms=false versions:set |
| 75 | + |
| 76 | + - name: Build and Deploy |
| 77 | + env: |
| 78 | + MAVEN_DEPLOY_USERNAME: "aws" |
| 79 | + MAVEN_DEPLOY_PASSWORD: ${{ steps.codeartifact.outputs.repo_token }} |
| 80 | + run: | |
| 81 | + mvn $MVN_OPTS clean package deploy \ |
| 82 | + -DaltDeploymentRepository=inpart-maven-releases::default::${{ steps.codeartifact.outputs.repo_url }} |
0 commit comments