Update main.yml #21
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: | |
- actions # Trigger this workflow on pushes to the "actions" branch | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '8' # Use the appropriate JDK version | |
distribution: 'adopt' # Set the Java distribution | |
- name: Install Ant | |
run: sudo apt-get install -y ant | |
- name: Build the project | |
run: ant -Dskip.chkpii=y # Run the specified Ant command | |
- name: List files in dist directory | |
run: ls -l dist # Debugging step to list files | |
- name: Create GitHub release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "actions-${{ github.sha }}" # Tag name format | |
release_name: "Release for actions-${{ github.sha }}" # Release name format | |
body: | | |
Release notes for actions-${{ github.sha }}. | |
draft: false | |
prerelease: false | |
- name: Upload release assets | |
run: | | |
for file in dist/*.zip; do | |
if [ -f "$file" ]; then | |
echo "Uploading $file" | |
curl -X POST \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @"$file" \ | |
"${{ steps.create_release.outputs.upload_url }}&name=$(basename "$file")" \ | |
|| echo "Failed to upload $file" # Added error handling | |
fi | |
done |