Skip to content

Commit 80d1baa

Browse files
authored
Merge pull request #1 from LinuxSuRen/feat/image
feat: support github actions uses images
2 parents eb83d67 + f7cfee6 commit 80d1baa

File tree

8 files changed

+97
-0
lines changed

8 files changed

+97
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
UpdateReleaseDraft:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- uses: release-drafter/release-drafter@v5
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}

.github/workflows/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-20.04
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3.0.0
14+
- name: Unshallow
15+
run: git fetch --prune --unshallow
16+
- name: Set up Go
17+
uses: actions/setup-go@v3
18+
with:
19+
go-version: 1.19
20+
- name: Run GoReleaser
21+
uses: goreleaser/goreleaser-action@v2.9.1
22+
with:
23+
version: latest
24+
args: release --rm-dist
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ build:
22
go build -o bin/gaw .
33
copy: build
44
cp bin/gaw /usr/local/bin
5+
test-gh:
6+
act -W pkg/data/ -j imageTest

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22

33
# github-action-workflow
44
GitHub Actions compatible workflows
5+
6+
## Usage
7+
8+
```shell
9+
gaw convert .github/workflows/pull-request.yaml
10+
```

pkg/argo-workflow.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func (w *Workflow) ConvertToArgoWorkflow() (output string, err error) {
3535
} else if strings.HasPrefix(w.Jobs[i].Steps[j].Uses, "goreleaser/goreleaser-action") {
3636
w.Jobs[i].Steps[j].Image = "goreleaser/goreleaser:v1.13.1"
3737
w.Jobs[i].Steps[j].Run = "goreleaser " + w.Jobs[i].Steps[j].With["args"]
38+
} else if strings.HasPrefix(w.Jobs[i].Steps[j].Uses, "docker://") {
39+
w.Jobs[i].Steps[j].Image = strings.TrimPrefix(w.Jobs[i].Steps[j].Uses, "docker://")
40+
w.Jobs[i].Steps[j].Run = w.Jobs[i].Steps[j].With["args"]
3841
} else if w.Jobs[i].Steps[j].Uses != "" {
3942
// TODO not support yet, do nothing
4043
} else {

pkg/argo-workflow_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func TestWorkflow_ConvertToArgoWorkflow(t *testing.T) {
1717
name: "simple",
1818
githubActions: "data/github-actions.yaml",
1919
argoWorkflows: "data/argo-workflows.yaml",
20+
}, {
21+
name: "with image",
22+
githubActions: "data/github-action-image.yaml",
23+
argoWorkflows: "data/argo-workflows-image.yaml",
2024
}}
2125
for _, tt := range tests {
2226
t.Run(tt.name, func(t *testing.T) {

pkg/data/argo-workflows-image.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: WorkflowTemplate
3+
metadata:
4+
name: imagetest
5+
spec:
6+
entrypoint: main
7+
volumeClaimTemplates:
8+
- metadata:
9+
name: work
10+
spec:
11+
accessModes: ["ReadWriteOnce"]
12+
resources:
13+
requests:
14+
storage: 64Mi
15+
16+
templates:
17+
- name: main
18+
dag:
19+
tasks:
20+
- name: test
21+
template: test
22+
- name: test
23+
script:
24+
image: alpine:3.8
25+
command: [sh]
26+
source: |
27+
echo 1
28+
volumeMounts:
29+
- mountPath: /work
30+
name: work
31+
workingDir: /work

pkg/data/github-action-image.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: imageTest
2+
3+
jobs:
4+
imageTest:
5+
name: build
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: test
9+
uses: docker://alpine:3.8
10+
with:
11+
args: echo 1

0 commit comments

Comments
 (0)