Skip to content

Commit a028a84

Browse files
Merge branch 'main' into support_github_app_auth
2 parents 78ebc01 + 19746b9 commit a028a84

File tree

10 files changed

+142
-106
lines changed

10 files changed

+142
-106
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414

1515
# Resources for the 'build-docker-image' task of the 'build' job
1616
/git/
17+
/golang-latest/
18+
/alpine-latest/
1719
/image/
1820
/cache/
1921

2022
# Resources for the 'build-docker-image' task of the 'build-pr' job
2123
/git-pull-requests/
24+
/golang-latest/
25+
/alpine-latest/
2226
/image/
2327
/cache/
2428

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ automated tests.
3737
## Source Configuration
3838

3939
| Parameter | Required | Example | Description |
40-
|-----------------------------|----------|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
40+
| --------------------------- | -------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
4141
| `repository` | Yes | `itsdalmo/test-repository` | The repository to target. |
42-
| `access_token` | Yes | | A Github Access Token with repository access (required for setting status on commits). N.B. If you want github-pr-resource to work with a private repository. Set `repo:full` permissions on the access token you create on GitHub. If it is a public repository, `repo:status` is enough. When using `trusted_teams`, the `read:org` scope has to be enabled. |
42+
| `access_token` | Yes | | A Github Access Token with repository access, which is required for setting status on commits. (See also the note below about required permissions.) |
4343
| `v3_endpoint` | No | `https://api.github.com` | Endpoint to use for the V3 Github API (Restful). |
4444
| `v4_endpoint` | No | `https://api.github.com/graphql` | Endpoint to use for the V4 Github API (Graphql). |
4545
| `paths` | No | `["terraform/*/*.tf"]` | Only produce new versions if the PR includes changes to files that match one or more glob patterns or prefixes. |
@@ -62,7 +62,13 @@ automated tests.
6262
| `installation_id` | No | `12356` | Installation id for your github app.
6363
| `application_id` | No | `12356` | Application id for your github app.
6464

65-
Notes:
65+
**Notes:**
66+
67+
- Required permissions for `access_token`:
68+
- if you want github-pr-resource to work with a private repository, set
69+
`repo:full` permissions on the access token you create on GitHub.
70+
- If it is a public repository, `repo:status` is enough.
71+
- When using `trusted_teams`, the `read:org` scope has to be enabled.
6672
- If `v3_endpoint` is set, `v4_endpoint` must also be set (and the other way around).
6773
- Look at the [Concourse Resources documentation](https://concourse-ci.org/resources.html#resource-webhook-token)
6874
for webhook token configuration.

ci/pipeline.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
# ci/settings.yml and override what needs overridden.
99
# This uses spruce, so you have some options there.
1010
#
11-
# author: James Hunt <[email protected]>
12-
# Dennis Bell <[email protected]>
13-
# created: 2016-03-04
11+
# original authors: James Hunt <[email protected]>
12+
# Dennis Bell <[email protected]>
13+
# created: 2016-03-04
14+
# maintainer: Benjamin Gandon (Gstack)
1415

1516
meta:
1617
name: (( param "Please name your pipeline" ))
@@ -104,6 +105,7 @@ jobs:
104105
put: notify
105106
no_get: true
106107
params:
108+
silent: true
107109
channel: (( grab meta.slack.channel ))
108110
username: (( grab meta.slack.username ))
109111
icon_url: (( grab meta.slack.icon ))
@@ -173,6 +175,7 @@ jobs:
173175
put: notify
174176
no_get: true
175177
params:
178+
silent: true
176179
channel: (( grab meta.slack.channel ))
177180
username: (( grab meta.slack.username ))
178181
icon_url: (( grab meta.slack.icon ))
@@ -217,6 +220,7 @@ jobs:
217220
put: notify
218221
no_get: true
219222
params:
223+
silent: true
220224
channel: (( grab meta.slack.channel ))
221225
username: (( grab meta.slack.username ))
222226
icon_url: (( grab meta.slack.icon ))
@@ -232,6 +236,7 @@ jobs:
232236
put: notify
233237
no_get: true
234238
params:
239+
silent: true
235240
channel: (( grab meta.slack.channel ))
236241
username: (( grab meta.slack.username ))
237242
icon_url: (( grab meta.slack.icon ))
@@ -247,6 +252,7 @@ jobs:
247252
put: notify
248253
no_get: true
249254
params:
255+
silent: true
250256
channel: (( grab meta.slack.channel ))
251257
username: (( grab meta.slack.username ))
252258
icon_url: (( grab meta.slack.icon ))
@@ -324,6 +330,7 @@ jobs:
324330
put: notify
325331
no_get: true
326332
params:
333+
silent: true
327334
channel: (( grab meta.slack.channel ))
328335
username: (( grab meta.slack.username ))
329336
icon_url: (( grab meta.slack.icon ))

ci/repipe

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
# Script for merging together pipeline configuration files
66
# (via Spruce!) and configuring Concourse.
77
#
8-
# author: James Hunt <[email protected]>
9-
# Dennis Bell <[email protected]>
10-
# created: 2016-03-04
8+
# original authors: James Hunt <[email protected]>
9+
# Dennis Bell <[email protected]>
10+
# created: 2016-03-04
11+
# maintainer: Benjamin Gandon (Gstack)
1112

1213
need_command() {
13-
local cmd=${1:?need_command() - no command name given}
14-
15-
if [[ ! -x "$(command -v $cmd)" ]]; then
16-
echo >&2 "${cmd} is not installed."
17-
if [[ "${cmd}" == "spruce" ]]; then
18-
echo >&2 "Please download it from https://github.com/geofffranks/spruce/releases"
19-
fi
20-
exit 2
21-
fi
14+
local cmd=${1:?"need_command() - no command name given"}
15+
16+
if [[ ! -x "$(command -v ${cmd})" ]]; then
17+
echo >&2 "${cmd} is not installed."
18+
if [[ "${cmd}" == "spruce" ]]; then
19+
echo >&2 "Please download it from https://github.com/geofffranks/spruce/releases"
20+
fi
21+
exit 2
22+
fi
2223
}
2324

2425
NO_FLY=
@@ -45,33 +46,35 @@ usage() {
4546
}
4647

4748
open_pipeline() {
48-
url=$(show_pipeline_url)
49+
url=$(show_pipeline_url)
4950
cleanup
50-
if [[ -x /usr/bin/open ]]; then
51-
exec /usr/bin/open "$url"
52-
else
53-
echo "Sorry, but I was not able to automagically open"
54-
echo "your Concourse Pipeline in the browser."
55-
echo
56-
echo "Here's a link you can click on, though:"
57-
echo
58-
echo " $url"
59-
echo
60-
exit 0;
61-
fi
51+
if [[ -x /usr/bin/open ]]; then
52+
exec /usr/bin/open "${url}"
53+
else
54+
echo "Sorry, but I was not able to automagically open"
55+
echo "your Concourse Pipeline in the browser."
56+
echo
57+
echo "Here's a link you can click on, though:"
58+
echo
59+
echo " ${url}"
60+
echo
61+
exit 0;
62+
fi
6263
}
6364

6465
show_pipeline_url() {
65-
spruce merge --skip-eval pipeline.yml ${settings_file} > .deploy.yml
66-
concourse_url=$(spruce json .deploy.yml | jq -r ".meta.url")
67-
team=$(spruce json .deploy.yml | jq -r ".meta.team // \"main\"")
68-
pipeline=$(spruce merge --skip-eval \
69-
--cherry-pick meta.pipeline \
70-
--cherry-pick meta.name \
71-
.deploy.yml | spruce merge - | spruce json | jq -r ".meta.pipeline")
72-
73-
echo "$concourse_url/teams/$team/pipelines/$pipeline"
74-
exit 0
66+
spruce merge --skip-eval pipeline.yml ${settings_file} > .deploy.yml
67+
concourse_url=$(spruce json .deploy.yml | jq -r ".meta.url")
68+
team=$(spruce json .deploy.yml | jq -r ".meta.team // \"main\"")
69+
pipeline=$(
70+
spruce merge --skip-eval \
71+
--cherry-pick meta.pipeline \
72+
--cherry-pick meta.name \
73+
.deploy.yml \
74+
| spruce merge - | spruce json | jq -r ".meta.pipeline"
75+
)
76+
echo "${concourse_url}/teams/${team}/pipelines/${pipeline}"
77+
exit 0
7578
}
7679

7780
for arg do
@@ -90,16 +93,16 @@ for arg do
9093
esac
9194
done
9295

93-
cd $(dirname $BASH_SOURCE[0])
96+
cd "$(dirname "${BASH_SOURCE[0]}")"
9497
echo >&2 "Working in $(pwd)"
9598
need_command spruce
9699

97100
# Allow for target-specific settings
98101
settings_file="$(ls -1 settings.yml ${CONCOURSE_TARGET:+"settings-${CONCOURSE_TARGET}.yml"} 2>/dev/null | head -n1)"
99-
if [[ -z "$settings_file" ]]
102+
if [[ -z "${settings_file}" ]]
100103
then
101-
echo >&2 "Missing local settings in ci/settings.yml${CONCOURSE_TARGET:+" or ci/settings-${CONCOURSE_TARGET}.yml"}!"
102-
exit 1
104+
echo >&2 "Missing local settings in ci/settings.yml${CONCOURSE_TARGET:+" or ci/settings-${CONCOURSE_TARGET}.yml"}!"
105+
exit 1
103106
fi
104107

105108
echo >&2 "Using settings found in ${settings_file}"
@@ -113,26 +116,26 @@ trap "cleanup" QUIT TERM EXIT INT
113116
spruce merge pipeline.yml ${settings_file} > .deploy.yml
114117
PIPELINE=$(spruce json .deploy.yml | jq -r '.meta.pipeline // ""')
115118
if [[ -z ${PIPELINE} ]]; then
116-
echo >&2 "Missing pipeline name in ci/settings.yml!"
117-
exit 1
119+
echo >&2 "Missing pipeline name in ci/settings.yml!"
120+
exit 1
118121
fi
119122

120123
TARGET_FROM_SETTINGS=$(spruce json .deploy.yml | jq -r '.meta.target // ""')
121124
if [[ -z ${CONCOURSE_TARGET} ]]; then
122-
TARGET=${TARGET_FROM_SETTINGS}
123-
elif [[ "$CONCOURSE_TARGET" != "$TARGET_FROM_SETTINGS" ]]
125+
TARGET=${TARGET_FROM_SETTINGS}
126+
elif [[ "${CONCOURSE_TARGET}" != "${TARGET_FROM_SETTINGS}" ]]
124127
then
125-
echo >&2 "Target in {$settings_file} differs from target in \$CONCOURSE_TARGET"
126-
echo >&2 " \$CONCOURSE_TARGET: $CONCOURSE_TARGET"
127-
echo >&2 " Target in file: $TARGET_FROM_SETTINGS"
128-
exit 1
128+
echo >&2 "Target in {${settings_file}} differs from target in \$CONCOURSE_TARGET"
129+
echo >&2 " \$CONCOURSE_TARGET: ${CONCOURSE_TARGET}"
130+
echo >&2 " Target in file: ${TARGET_FROM_SETTINGS}"
131+
exit 1
129132
else
130-
TARGET=${CONCOURSE_TARGET}
133+
TARGET=${CONCOURSE_TARGET}
131134
fi
132135

133136
if [[ -z ${TARGET} ]]; then
134-
echo >&2 "Missing Concourse Target in ci/settings.yml!"
135-
exit 1
137+
echo >&2 "Missing Concourse Target in ci/settings.yml!"
138+
exit 1
136139
fi
137140

138141
fly_cmd="${FLY_CMD:-fly}"
@@ -146,6 +149,6 @@ case "${VALIDATE_PIPELINE}" in
146149
esac
147150

148151
set +x
149-
$fly_cmd --target ${TARGET} ${fly_opts} --config .deploy.yml
152+
${fly_cmd} --target ${TARGET} ${fly_opts} --config .deploy.yml
150153
[[ -n ${VALIDATE_PIPELINE} ]] && exit 0
151-
$fly_cmd --target ${TARGET} unpause-pipeline --pipeline ${PIPELINE}
154+
${fly_cmd} --target ${TARGET} unpause-pipeline --pipeline ${PIPELINE}

ci/scripts/release

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,63 @@
55
# Script for generating Github release / tag assets
66
# and managing release notes for a Docker Image pipeline
77
#
8-
# author: James Hunt <[email protected]>
9-
# Dennis Bell <[email protected]>
10-
# created: 2016-03-04
8+
# original authors: James Hunt <[email protected]>
9+
# Dennis Bell <[email protected]>
10+
# created: 2016-03-04
11+
# maintainer: Benjamin Gandon (Gstack)
1112

1213
set -eu
1314

14-
: ${REPO_ROOT:?required}
15-
: ${RELEASE_ROOT:?required}
16-
: ${RELEASE_NAME:?required}
17-
: ${GIT_EMAIL:?required}
18-
: ${GIT_NAME:?required}
15+
: ${REPO_ROOT:?"required"}
16+
: ${RELEASE_ROOT:?"required"}
17+
: ${RELEASE_NAME:?"required"}
18+
: ${GIT_EMAIL:?"required"}
19+
: ${GIT_NAME:?"required"}
1920
RELEASE_BRANCH=${RELEASE_BRANCH:-"master"}
20-
: ${REPO_OUT:?required}
21+
: ${REPO_OUT:?"required"}
2122

2223
if [[ ! -f ${REPO_ROOT}/ci/release_notes.md ]]; then
23-
echo >&2 "ci/release_notes.md not found. Did you forget to write them?"
24-
exit 1
24+
echo >&2 "ci/release_notes.md not found. Did you forget to write them?"
25+
exit 1
2526
fi
2627

27-
if [[ -z ${VERSION_FROM} ]]; then
28-
echo >&2 "VERSION_FROM environment variable not set, or empty. Did you misconfigure Concourse?"
29-
exit 2
28+
if [[ -z "${VERSION_FROM}" ]]; then
29+
echo >&2 "VERSION_FROM environment variable not set, or empty. Did you misconfigure Concourse?"
30+
exit 2
3031
fi
3132
if [[ ! -f ${VERSION_FROM} ]]; then
32-
echo >&2 "Version file (${VERSION_FROM}) not found. Did you misconfigure Concourse?"
33-
exit 2
33+
echo >&2 "Version file (${VERSION_FROM}) not found. Did you misconfigure Concourse?"
34+
exit 2
3435
fi
35-
VERSION=$(cat ${VERSION_FROM})
36-
if [[ -z ${VERSION} ]]; then
37-
echo >&2 "Version file (${VERSION_FROM}) was empty. Did you misconfigure Concourse?"
38-
exit 2
36+
version=$(cat ${VERSION_FROM})
37+
if [[ -z "${version}" ]]; then
38+
echo >&2 "Version file (${VERSION_FROM}) was empty. Did you misconfigure Concourse?"
39+
exit 2
3940
fi
4041

41-
echo "v${VERSION}" > ${RELEASE_ROOT}/tag
42-
echo "${RELEASE_NAME} v${VERSION}" > ${RELEASE_ROOT}/name
42+
echo "v${version}" > ${RELEASE_ROOT}/tag
43+
echo "${RELEASE_NAME} v${version}" > ${RELEASE_ROOT}/name
4344
mv ${REPO_ROOT}/ci/release_notes.md ${RELEASE_ROOT}/notes.md
4445

4546
# GIT!
4647
if [[ -z $(git config --global user.email) ]]; then
47-
git config --global user.email "${GIT_EMAIL}"
48+
git config --global user.email "${GIT_EMAIL}"
4849
fi
4950
if [[ -z $(git config --global user.name) ]]; then
50-
git config --global user.name "${GIT_NAME}"
51+
git config --global user.name "${GIT_NAME}"
5152
fi
5253

53-
(cd ${REPO_ROOT}
54-
git merge --no-edit "${RELEASE_BRANCH}"
55-
git add -A
56-
git status
57-
git commit -m "release v${VERSION} [skip ci]")
54+
(
55+
cd ${REPO_ROOT}
56+
git merge --no-edit "${RELEASE_BRANCH}"
57+
git add -A
58+
git status
59+
git commit -m "release v${version} [skip ci]"
60+
)
5861

5962
# so that future steps in the pipeline can push our changes
6063
cp -a ${REPO_ROOT} ${REPO_OUT}
6164

6265
sed -e '/START_OF_DOCKERHUB_STRIP/,/END_OF_DOCKERHUB_STRIP/d' \
63-
git/README.md \
64-
> dockerhub/README.md
66+
git/README.md \
67+
> dockerhub/README.md

ci/scripts/update-dockerhub-readme

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
# author: Benjamin Gandon (Gstack)
4+
# created: 2021-12-13
5+
36
set -euo pipefail
47

58
: ${DOCKERHUB_USERNAME:?"required"}
@@ -10,18 +13,20 @@ set -euo pipefail
1013
payload=$(jq --null-input \
1114
--arg "username" "${DOCKERHUB_USERNAME}" \
1215
--arg "password" "${DOCKERHUB_PASSWORD}" \
13-
'{ "username": $username, "password": $password }')
16+
'{ "username": $username, "password": $password }'
17+
)
1418

1519
curl --silent --fail --show-error --location \
16-
--request "POST" \
17-
--url "https://hub.docker.com/v2/users/login" \
18-
--header "Content-Type: application/json" \
19-
--data-raw "${payload}" \
20-
> ./token.json
20+
--request "POST" \
21+
--url "https://hub.docker.com/v2/users/login" \
22+
--header "Content-Type: application/json" \
23+
--data-raw "${payload}" \
24+
> ./token.json
2125

2226
payload=$(jq --null-input \
2327
--arg "full_description" "$(cat dockerhub/README.md)" \
24-
'{ "full_description": $full_description }')
28+
'{ "full_description": $full_description }'
29+
)
2530

2631
curl --silent --fail --show-error --location --include \
2732
--request "PATCH" \

0 commit comments

Comments
 (0)