Skip to content

Commit 987afc0

Browse files
authored
Merge pull request #37 from CoverGo/f/BE-651-add-github-token-to-docker
feat: add GITHUB_TOKEN as an argument to build
2 parents 2c07ff6 + d8f64c7 commit 987afc0

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

.gflows/libs/steps.lib.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ with:
1818
#@ def _checkout():
1919
name: Checkout repository
2020
uses: actions/checkout@v3
21-
#@ end
21+
#@ end
2222
---
2323
#@ def _generate_docker_meta():
2424
#@ custom_labels = []
@@ -29,12 +29,12 @@ uses: docker/metadata-action@v3
2929
with:
3030
images: name/app
3131
labels: #@ "\n".join(custom_labels)
32-
#@ end
32+
#@ end
3333
---
3434
#@ def _setup_qemu():
3535
name: Set up QEMU
3636
uses: docker/setup-qemu-action@v1
37-
#@ end
37+
#@ end
3838
---
3939
#@ def _setup_buildx():
4040
name: Set up Docker Buildx
@@ -62,7 +62,7 @@ with:
6262
#@ def _build_and_push_docker(component, cache_registry, step_name=None, step_id=None, push_image=True, load_image=False, tags=None, build_versioned_image = False):
6363
name: #@ common.get_value(step_name, job.name.docker_build(component.name))
6464
uses: docker/build-push-action@v3
65-
#@ if step_id != None :
65+
#@ if step_id != None :
6666
id: #@ step_id
6767
#@ end
6868
#@ if tags == None :
@@ -80,10 +80,10 @@ id: #@ step_id
8080
#@ for cache_image in cache_images:
8181
#@ cache_refs.append("type=registry,ref={}".format(cache_image))
8282
#@ end
83-
#@
83+
#@
8484
#@ cache_from_multiline_string = "\n".join(cache_refs)
8585
#@ cache_registry = struct.make(cache_from =cache_from_multiline_string, cache_to = "type=registry,ref={},mode={}".format(own_cache_image,getattr(component,"cache_mode","max")))
86-
86+
8787
#@ cache_params = {"gha":cache_gha, "registry":cache_registry}
8888

8989
#@ cache_type = cfg.get_cache_type(component)
@@ -104,7 +104,7 @@ with:
104104
#@ end
105105
#@ if cfg.should_push_cache(component):
106106
cache-to: #@ cache_params[cache_type].cache_to
107-
#@ end
107+
#@ end
108108
#@ if hasattr(component,"docker_target"):
109109
target: #@ component.docker_target
110110
#@ end
@@ -113,6 +113,7 @@ with:
113113
#@ build_args += component.build_args
114114
#@ end
115115
#@ build_args.append("COMMIT_SHA=${{ github.sha }}")
116+
#@ build_args.append("GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}")
116117
#@ if build_versioned_image:
117118
#@ build_args.append("BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}")
118119
#@ build_args.append("APP_VERSION=${{ needs.version.outputs.app_version }}")
@@ -152,4 +153,4 @@ run: #@ "echo ${{ steps." + step_id + ".outputs.digest }}"
152153
#@ generate_docker_meta = _generate_docker_meta,
153154
#@ define_docker_outputs = _define_docker_outputs,
154155
#@ echo_docker_digest = _echo_docker_digest)
155-
---
156+
---

github-sample/workflows/build-publish.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ jobs:
112112
type=registry,ref=ghcr.io/covergo/auth-nuget-cache:${{ needs.version.outputs.issue_id_slug }}
113113
build-args: |-
114114
COMMIT_SHA=${{ github.sha }}
115+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
115116
BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
116117
APP_VERSION=${{ needs.version.outputs.app_version }}
117118
FILE_VERSION=${{ needs.version.outputs.file_version }}
@@ -184,6 +185,7 @@ jobs:
184185
cache-to: type=registry,ref=ghcr.io/covergo/auth-nuget-default-cache:${{ needs.version.outputs.issue_id_slug }},mode=max
185186
build-args: |-
186187
COMMIT_SHA=${{ github.sha }}
188+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
187189
BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
188190
APP_VERSION=${{ needs.version.outputs.app_version }}
189191
FILE_VERSION=${{ needs.version.outputs.file_version }}
@@ -269,6 +271,7 @@ jobs:
269271
build-args: |-
270272
NOW="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
271273
COMMIT_SHA=${{ github.sha }}
274+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
272275
BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
273276
APP_VERSION=${{ needs.version.outputs.app_version }}
274277
FILE_VERSION=${{ needs.version.outputs.file_version }}
@@ -318,6 +321,7 @@ jobs:
318321
target: build-predeployment
319322
build-args: |-
320323
COMMIT_SHA=${{ github.sha }}
324+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
321325
BUILD_DATETIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
322326
APP_VERSION=${{ needs.version.outputs.app_version }}
323327
FILE_VERSION=${{ needs.version.outputs.file_version }}
@@ -359,7 +363,9 @@ jobs:
359363
type=registry,ref=ghcr.io/covergo/auth-cache:${{ needs.version.outputs.issue_id_slug }}
360364
type=registry,ref=ghcr.io/covergo/auth-test-unit-cache:${{ needs.version.outputs.issue_id_slug }}
361365
cache-to: type=registry,ref=ghcr.io/covergo/auth-test-unit-cache:${{ needs.version.outputs.issue_id_slug }},mode=min
362-
build-args: COMMIT_SHA=${{ github.sha }}
366+
build-args: |-
367+
COMMIT_SHA=${{ github.sha }}
368+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
363369
- name: Image digest
364370
run: echo ${{ steps.docker-build-auth-test-unit.outputs.digest }}
365371
run-auth-test-unit:
@@ -448,7 +454,9 @@ jobs:
448454
type=registry,ref=ghcr.io/covergo/auth-test-unit-cache:${{ needs.version.outputs.issue_id_slug }}
449455
type=registry,ref=ghcr.io/covergo/cases-mariadb-test-integration-cache:${{ needs.version.outputs.issue_id_slug }}
450456
cache-to: type=registry,ref=ghcr.io/covergo/cases-mariadb-test-integration-cache:${{ needs.version.outputs.issue_id_slug }},mode=max
451-
build-args: COMMIT_SHA=${{ github.sha }}
457+
build-args: |-
458+
COMMIT_SHA=${{ github.sha }}
459+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
452460
- name: Image digest
453461
run: echo ${{ steps.docker-build-integration-tests.outputs.digest }}
454462
- name: Checkout repository
@@ -553,7 +561,9 @@ jobs:
553561
type=registry,ref=ghcr.io/covergo/cases-api-test-integration-cache:${{ needs.version.outputs.issue_id_slug }}
554562
type=registry,ref=ghcr.io/covergo/cases-test-acceptance-cache:${{ needs.version.outputs.issue_id_slug }}
555563
cache-to: type=registry,ref=ghcr.io/covergo/cases-test-acceptance-cache:${{ needs.version.outputs.issue_id_slug }},mode=max
556-
build-args: COMMIT_SHA=${{ github.sha }}
564+
build-args: |-
565+
COMMIT_SHA=${{ github.sha }}
566+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
557567
- name: Image digest
558568
run: echo ${{ steps.docker-build-acceptance-tests.outputs.digest }}
559569
run-acceptance-tests:
@@ -687,7 +697,9 @@ jobs:
687697
type=registry,ref=ghcr.io/covergo/auth-test-unit-cache:${{ needs.version.outputs.issue_id_slug }}
688698
type=registry,ref=ghcr.io/covergo/cases-api-test-integration-cache:${{ needs.version.outputs.issue_id_slug }}
689699
cache-to: type=registry,ref=ghcr.io/covergo/cases-api-test-integration-cache:${{ needs.version.outputs.issue_id_slug }},mode=max
690-
build-args: COMMIT_SHA=${{ github.sha }}
700+
build-args: |-
701+
COMMIT_SHA=${{ github.sha }}
702+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
691703
- name: Image digest
692704
run: echo ${{ steps.docker-build-api-test-integration.outputs.digest }}
693705
run-api-test-integration:
@@ -1124,7 +1136,9 @@ jobs:
11241136
tags: ghcr.io/covergo/auth-mongo:${{ needs.version.outputs.app_version }}
11251137
cache-from: type=registry,ref=ghcr.io/covergo/auth-mongo-cache:${{ needs.version.outputs.issue_id_slug }}
11261138
cache-to: type=registry,ref=ghcr.io/covergo/auth-mongo-cache:${{ needs.version.outputs.issue_id_slug }},mode=max
1127-
build-args: COMMIT_SHA=${{ github.sha }}
1139+
build-args: |-
1140+
COMMIT_SHA=${{ github.sha }}
1141+
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
11281142
- name: Image digest
11291143
run: echo ${{ steps.docker-build-auth-mongo.outputs.digest }}
11301144
deploy-tenant-tahoe:

0 commit comments

Comments
 (0)