Skip to content

Commit

Permalink
remove vault build args docker-push
Browse files Browse the repository at this point in the history
  • Loading branch information
robwhitby committed Sep 8, 2023
1 parent c0cc2b4 commit aa86312
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 91 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/for-dependabot-to-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,21 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
context: .
file: e2e/actions/docker-push/Dockerfile
platforms: linux/amd64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: eu.gcr.io/halfpipe-io/cache/blah:${{ env.GIT_REVISION }}
- name: Run Trivy vulnerability scanner
uses: docker://aquasec/trivy
Expand Down
6 changes: 3 additions & 3 deletions defaults/task_docker_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func dockerPushDefaulter(original manifest.DockerPush, man manifest.Manifest, de
updated.Secrets["ARTIFACTORY_PASSWORD"] = defaults.Artifactory.Password
}
if man.Platform.IsActions() {
updated.Secrets["ARTIFACTORY_URL"] = "${{ secrets.EE_ARTIFACTORY_URL }}"
updated.Secrets["ARTIFACTORY_USERNAME"] = "${{ secrets.EE_ARTIFACTORY_USERNAME }}"
updated.Secrets["ARTIFACTORY_PASSWORD"] = "${{ secrets.EE_ARTIFACTORY_PASSWORD }}"
updated.Secrets["ARTIFACTORY_URL"] = ""
updated.Secrets["ARTIFACTORY_USERNAME"] = ""
updated.Secrets["ARTIFACTORY_PASSWORD"] = ""
}

return updated
Expand Down
20 changes: 9 additions & 11 deletions e2e/actions/deploy-katee/workflowExpected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
context: e2e/actions/deploy-katee
file: e2e/actions/deploy-katee/Dockerfile
platforms: linux/amd64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: eu.gcr.io/halfpipe-io/cache/halfpipe-team/someImage:${{ env.GIT_REVISION }}
- name: Run Trivy vulnerability scanner
uses: docker://aquasec/trivy
Expand Down
100 changes: 45 additions & 55 deletions e2e/actions/docker-push/workflowExpected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,21 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
context: e2e/actions/docker-push
file: e2e/actions/docker-push/Dockerfile
platforms: linux/amd64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: eu.gcr.io/halfpipe-io/cache/someImage:${{ env.GIT_REVISION }}
- name: Run Trivy vulnerability scanner
uses: docker://aquasec/trivy
Expand Down Expand Up @@ -158,26 +156,24 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BAR=bar
BLAH=${{ steps.secrets.outputs.springernature_data_halfpipe-team_very_secret }}
BUILD_VERSION=2.${{ github.run_number }}.0
BUILD_VERSION
FOO=foo
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
GIT_REVISION
RUNNING_IN_CI
context: e2e/actions/docker-push
file: e2e/actions/docker-push/Dockerfile2
platforms: linux/amd64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: eu.gcr.io/halfpipe-io/cache/dockerhubusername/someImage:${{ env.GIT_REVISION }}
- name: Run Trivy vulnerability scanner
uses: docker://aquasec/trivy
Expand Down Expand Up @@ -229,23 +225,21 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
context: e2e/actions/docker-push
file: e2e/actions/docker-push/Dockerfile
platforms: linux/amd64,linux/arm64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: eu.gcr.io/halfpipe-io/cache/someImage:${{ env.GIT_REVISION }}
- name: Run Trivy vulnerability scanner
uses: docker://aquasec/trivy
Expand Down Expand Up @@ -297,14 +291,12 @@ jobs:
uses: docker/build-push-action@v4
with:
build-args: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
cache-from: type=registry,ref=eu.gcr.io/halfpipe-io/cache/someImage:buildcache
cache-to: type=inline
context: e2e/actions/docker-push
Expand All @@ -313,9 +305,9 @@ jobs:
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
tags: |-
eu.gcr.io/halfpipe-io/cache/someImage:${{ env.GIT_REVISION }}
eu.gcr.io/halfpipe-io/cache/someImage:buildcache
Expand Down Expand Up @@ -374,24 +366,22 @@ jobs:
with:
build-args: |
A=a
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
B=b
BUILD_VERSION=2.${{ github.run_number }}.0
GIT_REVISION=${{ github.sha }}
RUNNING_IN_CI=true
VAULT_ROLE_ID=${{ secrets.VAULT_ROLE_ID }}
VAULT_SECRET_ID=${{ secrets.VAULT_SECRET_ID }}
BUILD_VERSION
GIT_REVISION
RUNNING_IN_CI
context: e2e/actions/docker-push
file: e2e/actions/docker-push/Dockerfile
platforms: linux/amd64
provenance: false
push: true
secrets: |
ARTIFACTORY_PASSWORD=${{ secrets.EE_ARTIFACTORY_PASSWORD }}
ARTIFACTORY_URL=${{ secrets.EE_ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME=${{ secrets.EE_ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD
ARTIFACTORY_URL
ARTIFACTORY_USERNAME
C=${{ steps.secrets.outputs.springernature_data_halfpipe-team_secret_c }}
D=d
tags: eu.gcr.io/halfpipe-io/cache/someImage:${{ env.GIT_REVISION }}
Expand Down
24 changes: 14 additions & 10 deletions renderers/actions/docker_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ import (

func (a *Actions) dockerPushSteps(task manifest.DockerPush) (steps Steps) {
steps = dockerLogin(task.Image, task.Username, task.Password)
buildArgs := map[string]string{}
for k, v := range globalEnv {
buildArgs[k] = v
}
for k, v := range task.Vars {
buildArgs[k] = v
}

steps = append(steps, buildImage(a, task, buildArgs))
steps = append(steps, buildImage(a, task))
steps = append(steps, scanImage(a, task))
steps = append(steps, pushImage(task))
steps = append(steps, repositoryDispatch(task.Image))
Expand All @@ -46,7 +38,19 @@ func repositoryDispatch(eventName string) Step {
}
}

func buildImage(a *Actions, task manifest.DockerPush, buildArgs map[string]string) Step {
func buildImage(a *Actions, task manifest.DockerPush) Step {
buildArgs := map[string]string{
"ARTIFACTORY_PASSWORD": "",
"ARTIFACTORY_URL": "",
"ARTIFACTORY_USERNAME": "",
"BUILD_VERSION": "",
"GIT_REVISION": "",
"RUNNING_IN_CI": "",
}
for k, v := range task.Vars {
buildArgs[k] = v
}

step := Step{
Name: "Build Image",
Uses: "docker/build-push-action@v4",
Expand Down
6 changes: 5 additions & 1 deletion renderers/actions/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ type MultiLine struct {
func (ml MultiLine) MarshalYAML() (interface{}, error) {
var out []string
for k, v := range ml.m {
out = append(out, fmt.Sprintf("%s=%s\n", k, v))
if v == "" {
out = append(out, fmt.Sprintf("%s\n", k))
} else {
out = append(out, fmt.Sprintf("%s=%s\n", k, v))
}
}
sort.Strings(out)

Expand Down

0 comments on commit aa86312

Please sign in to comment.