|
| 1 | +# inspired by https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 2 | +name: Build & Push SwaggerEditor@next Docker image |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_run: |
| 6 | + workflows: ["SwaggerEditor@next build", "SwaggerEditor@next nightly build"] |
| 7 | + types: |
| 8 | + - completed |
| 9 | + branches: [next] |
| 10 | + |
| 11 | +jobs: |
| 12 | + |
| 13 | + build-push: |
| 14 | + if: > |
| 15 | + github.event.workflow_run.event == 'push' && |
| 16 | + github.event.workflow_run.conclusion == 'success' |
| 17 | + name: Deploy SwaggerEditor@next to Rancher |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + ref: next |
| 24 | + - name: 'Download build artifact' |
| 25 | + uses: actions/github-script@v6 |
| 26 | + with: |
| 27 | + script: | |
| 28 | + const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo, |
| 31 | + run_id: context.payload.workflow_run.id, |
| 32 | + }); |
| 33 | + const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { |
| 34 | + return artifact.name == "build" |
| 35 | + })[0]; |
| 36 | + const download = await github.rest.actions.downloadArtifact({ |
| 37 | + owner: context.repo.owner, |
| 38 | + repo: context.repo.repo, |
| 39 | + artifact_id: matchArtifact.id, |
| 40 | + archive_format: 'zip', |
| 41 | + }); |
| 42 | + const fs = require('fs'); |
| 43 | + fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data)); |
| 44 | + - run: | |
| 45 | + mkdir build |
| 46 | + unzip build.zip -d build |
| 47 | + - name: Set up QEMU |
| 48 | + uses: docker/setup-qemu-action@v2 |
| 49 | + |
| 50 | + - name: Set up Docker Buildx |
| 51 | + uses: docker/setup-buildx-action@v2 |
| 52 | + |
| 53 | + - name: Log in to DockerHub |
| 54 | + uses: docker/login-action@v2 |
| 55 | + with: |
| 56 | + username: ${{ secrets.DOCKERHUB_SB_USERNAME }} |
| 57 | + password: ${{ secrets.DOCKERHUB_SB_PASSWORD }} |
| 58 | + |
| 59 | + - name: Build docker image and push |
| 60 | + uses: docker/build-push-action@v3 |
| 61 | + with: |
| 62 | + context: . |
| 63 | + push: true |
| 64 | + platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/ppc64le,linux/s390x |
| 65 | + tags: swaggerapi/swagger-editor:next-v5 |
0 commit comments