Skip to content

Merge pull request #4758 from SJuliez/#4734 #1375

Merge pull request #4758 from SJuliez/#4734

Merge pull request #4758 from SJuliez/#4734 #1375

# This workflow updates the MM Maven Repo on push to master
name: Update Maven Repo
on:
push:
branches: [ master ]
paths:
- 'megamek/src/**'
- 'megamek/i18n/**'
- 'megamek/resources/**'
jobs:
update_maven_repo:
runs-on: ${{ matrix.os }}
# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ ubuntu-latest ] # For Maven Repository Update running on *nix is sufficient
java-distribution: [ temurin ]
java-version: [ 17 ]
steps:
# Put the MM repo in a subfolder to make updating the Maven repo easier
- uses: actions/checkout@v3
with:
path: megamek
# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}
# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'
# Create the actual maven repo bits with Gradle
- name: Publish Maven Repo with Gradle
working-directory: megamek
run: ./gradlew publishPublishMMLibraryPublicationToMavenRepository
# Get the current Maven repo contents
- name: Checkout Maven Repo
if: github.repository == 'MegaMek/megamek'
uses: actions/checkout@v3
with:
repository: MegaMek/mavenrepo
path: mavenrepo
# Create an update
- name: Copy Maven Outputs to Repo
if: github.repository == 'MegaMek/megamek'
working-directory: megamek/megamek/build/mavenrepo/
run: |
cp -r . ../../../../mavenrepo/
# In case we run into an issue, use git status to help us understand what happened.
- name: Inspect git status output
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
git status
# Add the changes under the username and email of the user who pushed the code
- name: Commit changes to the Maven Repo
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
git add .
git config user.email ${{ github.event.pusher.email }}
git config user.name ${{ github.event.pusher.name }}
git commit -m "MegaMek ${{ github.event.after }}" -m "${{ github.event.compare }}"
# Use an SSH deploy key (with write privs) to update the maven repo
- name: Setup SSH and Push changes to the Maven Repo
if: github.repository == 'MegaMek/megamek'
working-directory: mavenrepo
run: |
eval "$(ssh-agent -s)"
ssh-add - <<< "${{ secrets.MAVEN_REPO_DEPLOY_KEY }}"
git push "git@github.com:MegaMek/mavenrepo.git" HEAD:master