Skip to content

Commit d850e81

Browse files
bdovaznvuillam
andauthored
Add GITHUB_AUTH_TOKEN as arg to Dockerfile to RUN commands using phive (#2314)
* Refactor token secret usage * Run build.sh * Try to fix linter errors * Build --------- Co-authored-by: nvuillam <[email protected]>
1 parent f0fe070 commit d850e81

File tree

5 files changed

+45
-24
lines changed

5 files changed

+45
-24
lines changed

Dockerfile

+11-6
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
326326
ENV PATH="$JAVA_HOME/bin:${PATH}"
327327

328328
# PHP installation
329-
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
329+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
330+
&& export GITHUB_AUTH_TOKEN \
331+
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
330332
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
331333
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
332334
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
@@ -508,19 +510,22 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P
508510
&& chmod 755 /usr/local/bin/checkmake \
509511

510512
# perlcritic installation
511-
&& curl --retry 5 --retry-delay 5 -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic \
513+
&& curl --retry 5 --retry-delay 5 -sL https://cpanmin.us/ | perl - -nq --no-wget Perl::Critic
512514

513515
# phpcs installation
514-
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
516+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
517+
515518

516519
# phpstan installation
517-
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
520+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
521+
518522

519523
# psalm installation
520-
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
524+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
525+
521526

522527
# phplint installation
523-
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
528+
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
524529
&& composer global config bin-dir --absolute \
525530

526531
# powershell installation

flavors/cupcake/Dockerfile

+12-6
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
265265
ENV PATH="$JAVA_HOME/bin:${PATH}"
266266

267267
# PHP installation
268-
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
268+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
269+
&& export GITHUB_AUTH_TOKEN \
270+
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
269271
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
270272
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
271273
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
@@ -363,19 +365,23 @@ RUN wget --quiet https://github.com/pmd/pmd/releases/download/pmd_releases%2F${P
363365
# checkmake installation
364366
&& ( [ -d /usr/local/bin ] || mkdir -p /usr/local/bin ) \
365367
&& wget -q "https://github.com/mrtazz/checkmake/releases/download/0.2.1/checkmake-0.2.1.linux.amd64" -O /usr/local/bin/checkmake \
366-
&& chmod 755 /usr/local/bin/checkmake \
368+
&& chmod 755 /usr/local/bin/checkmake
369+
367370

368371
# phpcs installation
369-
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
372+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
373+
370374

371375
# phpstan installation
372-
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
376+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
377+
373378

374379
# psalm installation
375-
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
380+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
381+
376382

377383
# phplint installation
378-
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
384+
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
379385
&& composer global config bin-dir --absolute \
380386

381387
# gitleaks installation

flavors/php/Dockerfile

+12-6
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
215215
#############################################################################################
216216
#OTHER__START
217217
# PHP installation
218-
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
218+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
219+
&& export GITHUB_AUTH_TOKEN \
220+
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
219221
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
220222
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
221223
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
@@ -279,19 +281,23 @@ RUN go install github.com/rhysd/actionlint/cmd/actionlint@latest && go clean --c
279281
&& tar xf ${ML_THIRD_PARTY_DIR}/kubeconform-linux-amd64.tar.gz --directory ${ML_THIRD_PARTY_DIR} \
280282
&& mv ${ML_THIRD_PARTY_DIR}/kubeconform /usr/local/bin \
281283
&& rm ${ML_THIRD_PARTY_DIR}/kubeconform-linux-amd64.tar.gz \
282-
&& find ${ML_THIRD_PARTY_DIR} -type f -not -name 'LICENSE*' -delete -o -type d -empty -delete \
284+
&& find ${ML_THIRD_PARTY_DIR} -type f -not -name 'LICENSE*' -delete -o -type d -empty -delete
285+
283286

284287
# phpcs installation
285-
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
288+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
289+
286290

287291
# phpstan installation
288-
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
292+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
293+
289294

290295
# psalm installation
291-
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
296+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
297+
292298

293299
# phplint installation
294-
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
300+
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
295301
&& composer global config bin-dir --absolute \
296302

297303
# protolint installation

linters/php_psalm/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \
134134
#############################################################################################
135135
#OTHER__START
136136
# PHP installation
137-
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
137+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
138+
&& export GITHUB_AUTH_TOKEN \
139+
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
138140
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
139141
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
140142
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
@@ -150,7 +152,7 @@ RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
150152
ENV PATH="/root/.composer/vendor/bin:$PATH"
151153

152154
# psalm installation
153-
RUN phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
155+
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
154156

155157

156158
#OTHER__END

megalinter/descriptors/php.megalinter-descriptor.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ install:
2121
- dpkg
2222
dockerfile:
2323
- |
24-
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
24+
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
25+
&& export GITHUB_AUTH_TOKEN \
26+
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
2527
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
2628
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
2729
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
@@ -52,7 +54,7 @@ linters:
5254
install:
5355
dockerfile:
5456
- |
55-
RUN phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
57+
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
5658
ide:
5759
atom:
5860
- name: linter-phpcs
@@ -96,7 +98,7 @@ linters:
9698
install:
9799
dockerfile:
98100
- |
99-
RUN phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
101+
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
100102
ide:
101103
idea:
102104
- name: PHPStan / Psalm / Generics
@@ -130,7 +132,7 @@ linters:
130132
install:
131133
dockerfile:
132134
- |
133-
RUN phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
135+
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
134136
ide:
135137
idea:
136138
- name: PHPStan / Psalm / Generics

0 commit comments

Comments
 (0)