diff --git a/.github/actions/build-plugin/action.yml b/.github/actions/build-plugin/action.yml index 6c206c59e..0e6977edd 100644 --- a/.github/actions/build-plugin/action.yml +++ b/.github/actions/build-plugin/action.yml @@ -1,6 +1,15 @@ name: 'Build Plugin' description: 'Builds plugin into ./build/commonsbooking' +inputs: + generate_zip: + description: 'Set to true, if a zip file should be generated in the root of the plugin folder' + required: false + default: 'false' + options: + - true + - false + runs: using: "composite" steps: @@ -30,6 +39,12 @@ runs: - run: npm ci --legacy-peer-deps --include=dev shell: bash - - name: Run build script + - name: Run build script (skip zip generation) + if: ${{ inputs.generate_zip == 'false' }} run: bin/build-zip.sh --skip-zip - shell: bash \ No newline at end of file + shell: bash + + - name: Run build script and generate zip file + if: ${{ inputs.generate_zip == 'true' }} + run: bin/build-zip.sh + shell: bash diff --git a/.github/workflows/zip-pr.yml b/.github/workflows/zip-pr.yml new file mode 100644 index 000000000..833f325c9 --- /dev/null +++ b/.github/workflows/zip-pr.yml @@ -0,0 +1,40 @@ +name: Build zip from PR +on: + pull_request: + branches: [ master ] + +jobs: + zip-rc: + runs-on: ubuntu-20.04 + steps: + + - uses: actions/checkout@v4 + + - uses: ./.github/actions/build-plugin + with: + generate_zip: 'true' + + - name: Upload zip + uses: Dylan700/sftp-upload-action@latest + with: + server: ${{ secrets.CBZIPUPLOAD_HOST }} + username: ${{ secrets.CBZIPUPLOAD_USER }} + key: ${{ secrets.CBZIPUPLOAD_KEY }} + uploads: | + ./ => ./cbzip/${{ github.event.number }}/ + ignore: | + !commonsbooking.zip + + - name: Comment on PR + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let fs = require('fs'); + let issue_number = ${{ github.event.number }}; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: '[Download zip](http://cbzip.v2202011131270131895.happysrv.de/${{ github.event.number}}/commonsbooking.zip' + });