diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index d0396af3d..286604467 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -450,10 +450,15 @@ jobs: -p ${namespace} \ -a ${account_id} + Release: needs: [Deploy] runs-on: ubuntu-latest - if: ${{ github.event.action == 'published' || github.event.action == 'prereleased' }} + if: ${{ + github.event.action == 'published' || + github.event.action == 'prereleased' || + (github.event_name == 'workflow_call' && inputs.release != 'none') || + github.event_name == 'workflow_dispatch'}} steps: - name: Checkout repository uses: actions/checkout@v3 @@ -484,63 +489,39 @@ jobs: [ -f "./scripts/deploy.sh" ] && echo "deploy.sh found" || echo "deploy.sh missing" [ -f "./scripts/restore_db.sh" ] && echo "restore_db.sh found" || echo "restore_db.sh missing" - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 + - name: Generate Release Tag + id: generate_tag + run: | + if [ "${{ github.event_name }}" == "release" ]; then + echo "tag_name=${{ github.ref_name }}" >> $GITHUB_OUTPUT + elif [ "${{ inputs.version_tag }}" != "master" ] && [ "${{ inputs.version_tag }}" != "" ]; then + echo "tag_name=${{ inputs.version_tag }}" >> $GITHUB_OUTPUT + else + # Generate a unique tag based on current timestamp and run number + TAG_NAME="v$(date +%Y%m%d-%H%M%S)-${{ github.run_number }}" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + fi + + - name: Create or Update GitHub Release + uses: softprops/action-gh-release@v1 with: - tag_name: ${{ github.ref_name }} - release_name: Release ${{ github.ref_name }} + tag_name: ${{ steps.generate_tag.outputs.tag_name }} + name: Release ${{ steps.generate_tag.outputs.tag_name }} body: | This release includes the following artifacts: - build_artifacts.zip - terraform_artifacts.zip - deploy.sh - restore_db.sh + + Generated from workflow run: ${{ github.run_number }} + Commit: ${{ github.sha }} draft: false prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Build Artifacts - if: ${{ hashFiles('./bin/build_artifacts.zip') != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./bin/build_artifacts.zip - asset_name: build_artifacts.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Terraform Artifacts - if: ${{ hashFiles('./bin/terraform_artifacts.zip') != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./bin/terraform_artifacts.zip - asset_name: terraform_artifacts.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Deploy Script - if: ${{ hashFiles('./scripts/deploy.sh') != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./scripts/deploy.sh - asset_name: deploy.sh - asset_content_type: text/x-shellscript - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload Restore DB Script - if: ${{ hashFiles('./scripts/restore_db.sh') != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./scripts/restore_db.sh - asset_name: restore_db.sh - asset_content_type: text/x-shellscript + files: | + ./bin/build_artifacts.zip + ./bin/terraform_artifacts.zip + ./scripts/deploy.sh + ./scripts/restore_db.sh env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file