Update publishPackage.yml #138
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
name: Build and Archive Jars | |
on: | |
push: | |
branches: | |
- origin # Change this to your branch name if it's called "origin" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: 'adopt' | |
- name: Build the project | |
run: ./gradlew build # Replace with your build command | |
- name: Archive Jars | |
run: | | |
commit_hash=$(git rev-parse --short HEAD) | |
jar_files=$(find build/libs -name "*.jar") | |
if [ -n "$jar_files" ]; then | |
zip -j builds/commits/${commit_hash}.zip ${jar_files} | |
if [ -f "builds/commits/${commit_hash}.zip" ]; then | |
if [ ! -f "builds/commits/${commit_hash}.zip.bak" ]; then | |
cp builds/commits/${commit_hash}.zip builds/commits/${commit_hash}.zip.bak | |
fi | |
fi | |
fi | |
shell: bash | |
- name: Commit and Push Archive | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git config --global user.email "[email protected]" | |
git config --global user.name "github-actions" | |
git config --global credential.helper 'store --file ~/.git-credentials' | |
echo "https://github.com/Dueris/GenesisMC:${{ secrets.GH_TOKEN }}" > ~/.git-credentials | |
if [ -f "builds/commits/${commit_hash}.zip" ]; then | |
git add builds/commits/${commit_hash}.zip | |
git commit -m "Add archive for commit ${commit_hash}" | |
git push | |
fi | |
- name: Notify Discord | |
if: ${{ (success() || failure()) }} | |
uses: Tim203/actions-git-discord-webhook@70f38ded3aca51635ec978ab4e1a58cd4cd0c2ff | |
with: | |
webhook_url: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ job.status }} |