Skip to content

Commit

Permalink
fix(dockerfile): take GITHUB_TOKEN from secrets (#748)
Browse files Browse the repository at this point in the history
## What

This takes `GITHUB_TOKEN` from secrets instead of build args.

## Why

Security reasons.

## Notes

—
  • Loading branch information
masontikhonov authored Apr 24, 2024
1 parent 6f3f1e8 commit ea96878
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ RUN adduser \
--uid 10001 \
codefresh

ARG GITHUB_TOKEN
RUN git config \
RUN --mount=type=secret,id=GITHUB_TOKEN \
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) \
git config \
--global \
url."https://github:${GITHUB_TOKEN}@github.com".insteadOf \
"https://github.com"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v0.1.62
VERSION=v0.1.63

OUT_DIR=dist
YEAR?=$(shell date +"%Y")
Expand Down
15 changes: 14 additions & 1 deletion build/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ steps:
on:
- success

prepare_build_secrets:
stage: Prepare
title: 'Prepare build secrets'
image: alpine
commands:
- export GITHUB_TOKEN_PATH=${{CF_VOLUME_PATH}}/GITHUB_TOKEN
- cf_export GITHUB_TOKEN_PATH
- echo $GITHUB_TOKEN > $GITHUB_TOKEN_PATH

compare_versions:
stage: Prepare
title: compare versions
Expand Down Expand Up @@ -121,8 +130,9 @@ steps:
buildkit: true
disable_push: true
build_arguments:
- GITHUB_TOKEN=${{GITHUB_TOKEN}}
- SEGMENT_WRITE_KEY=${{SEGMENT_WRITE_KEY}}
secrets:
- id=GITHUB_TOKEN,src=${{GITHUB_TOKEN_PATH}}
when:
condition:
all:
Expand All @@ -131,6 +141,9 @@ steps:
- name: compare_versions
on:
- success
- name: prepare_build_secrets
on:
- success

push_dev:
stage: Push Dev
Expand Down
4 changes: 2 additions & 2 deletions docs/releases/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.62/cf-linux-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.63/cf-linux-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-linux-amd64 /usr/local/bin/cf
Expand All @@ -36,7 +36,7 @@ cf version

```bash
# download and extract the binary
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.62/cf-darwin-amd64.tar.gz | tar zx
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.63/cf-darwin-amd64.tar.gz | tar zx

# move the binary to your $PATH
mv ./cf-darwin-amd64 /usr/local/bin/cf
Expand Down

0 comments on commit ea96878

Please sign in to comment.