Deploy to Nexus #8
Workflow file for this run
This file contains hidden or 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: Deploy to Nexus | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| cd easter | |
| npm install | |
| - name: Get package version | |
| id: version | |
| run: echo "PACKAGE_VERSION=$(jq -r .version easter/package.json)" >> $GITHUB_ENV | |
| - name: Build project | |
| run: | | |
| cd easter | |
| npm run build | |
| - name: Check if version already exists in Nexus | |
| run: | | |
| VERSION=${{ env.PACKAGE_VERSION }} | |
| STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" -u "${{ secrets.NEXUS_USER }}:${{ secrets.NEXUS_PASSWORD }}" \ | |
| "https://nexus.aerius.nl/repository/js-releases/easter/${VERSION}/") | |
| if [ "$STATUS_CODE" == "200" ]; then | |
| echo "Error: Version ${VERSION} already exists in Nexus. Aborting." | |
| exit 1 | |
| fi | |
| - name: Upload built files to Nexus | |
| run: | | |
| VERSION=${{ env.PACKAGE_VERSION }} | |
| for file in $(find easter/dist -type f); do | |
| REL_PATH=${file#easter/dist/} # Remove leading directory | |
| curl -u "${{ secrets.NEXUS_USER }}:${{ secrets.NEXUS_PASSWORD }}" \ | |
| --upload-file "$file" \ | |
| "https://nexus.aerius.nl/repository/js-releases/easter/${VERSION}/${REL_PATH}" | |
| done |