Skip to content

Commit 420213b

Browse files
authored
ci: reflect changes to GitHub workflows from master (#3673)
Refs #3656
1 parent 6ff7318 commit 420213b

File tree

2 files changed

+66
-48
lines changed

2 files changed

+66
-48
lines changed

.github/workflows/deploy-rancher.yml

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Deploy SwaggerEditor@next to Rancher🚢
33

44
on:
55
workflow_run:
6-
workflows: ["SwaggerEditor@next build", "SwaggerEditor@next nightly build"]
6+
workflows: ["Build & Push SwaggerEditor@next Docker image"]
77
types:
88
- completed
99
branches: [next]
@@ -18,53 +18,6 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
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-
48-
- name: Set up QEMU
49-
uses: docker/setup-qemu-action@v2
50-
51-
- name: Set up Docker Buildx
52-
uses: docker/setup-buildx-action@v2
53-
54-
- name: Log in to DockerHub
55-
uses: docker/login-action@v2
56-
with:
57-
username: ${{ secrets.DOCKERHUB_SB_USERNAME }}
58-
password: ${{ secrets.DOCKERHUB_SB_PASSWORD }}
59-
60-
- name: Build docker image and push
61-
uses: docker/build-push-action@v3
62-
with:
63-
context: .
64-
push: true
65-
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/ppc64le,linux/s390x
66-
tags: swaggerapi/swagger-editor:next-v5
67-
6821
- name: Deploy Rancher🚢
6922
run: |
7023
ts="$(date +'%Y-%m-%dT%H:%M:%SZ' --utc)"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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

Comments
 (0)