remove multiple os from maven test #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/maven-deploy.yml | ||
name: Maven Deploy | ||
on: | ||
workflow_call: | ||
inputs: | ||
java-version: | ||
required: false | ||
default: '17' | ||
type: string | ||
jobs: | ||
find_folders_with_dockerfile: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
folders: ${{ steps.get_folders.outputs.folders }} | ||
steps: | ||
- name: Find all folders with Dockerfile | ||
id: get_folders | ||
run: | | ||
folders=$(find . -type f -name 'Dockerfile' -exec dirname {} \; | jq -R -s -c 'split("\n")[:-1]') | ||
echo "folders=${folders}" > $GITHUB_OUTPUT | ||
maven-deploy: | ||
needs: find_folders_with_dockerfile | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
folder: ${{ fromJson(needs.find_folders_with_dockerfile.outputs.folders) }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
- name: AWS Credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
aws-region: eu-west-1 | ||
role-to-assume: arn:aws:iam::917951871879:role/GitHubActionsBgOrg | ||
- name: Get CodeArtifact Authorization Token | ||
run: | | ||
codeartifact_auth_token=$(aws codeartifact get-authorization-token --domain nisv-ateam --domain-owner 917951871879 --region eu-west-1 --query authorizationToken --output text) | ||
echo "::add-mask::$codeartifact_auth_token" | ||
echo "codeartifact_auth_token=$codeartifact_auth_token" >> "$GITHUB_ENV" | ||
- name: Set up JDK | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'temurin' | ||
java-version: ${{ matrix.java-version }} | ||
server-id: 'code-artifact' | ||
server-username: 'aws' | ||
server-password: ${{ env.codeartifact_auth_token }} | ||
- name: Cache Maven packages | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/.m2/repository | ||
key: "${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}" | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Maven Deploy | ||
run: | | ||
set -o pipefail | ||
if [[ ${{ github.ref }} == refs/tags/* ]]; then | ||
mvn clean deploy -U -DaltDeploymentRepository=code-artifact::default::https://nisv-ateam-917951871879.d.codeartifact.eu-west-1.amazonaws.com/maven/releases/ | ||
else | ||
mvn clean deploy -Pcode-artifact | ||
fi | ||
- name: Setup Docker Buildx | ||
if: ${{ matrix.folder != '' }} | ||
uses: docker/[email protected] | ||
- name: ECR Login | ||
if: ${{ matrix.folder != '' }} | ||
uses: aws-actions/[email protected] | ||
- name: Get Image tag | ||
run: | | ||
echo "IMAGE_TAG=$(find "${{ matrix.folder }}/target" -type f -name "*.war")-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV | ||
- name: Build and push Docker images | ||
uses: docker/[email protected] | ||
with: | ||
context: ${{ matrix.folder }} | ||
push: true | ||
tags: '917951871879.dkr.ecr.eu-west-1.amazonaws.com'/${{ github.event.repository.name }}:${{ env.IMAGE_TAG }} | ||