Skip to content

Commit

Permalink
Add GITHUB_AUTH_TOKEN as arg to Dockerfile to RUN commands using phive (
Browse files Browse the repository at this point in the history
#2314)

* Refactor token secret usage

* Run build.sh

* Try to fix linter errors

* Build

---------

Co-authored-by: nvuillam <nicolas.vuillamy@gmail.com>
  • Loading branch information
bdovaz and nvuillam authored Feb 11, 2023
1 parent f0fe070 commit d850e81
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 24 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"

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

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

# phpcs installation
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
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


# phpstan installation
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
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


# psalm installation
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
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


# phplint installation
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
&& composer global config bin-dir --absolute \

# powershell installation
Expand Down
18 changes: 12 additions & 6 deletions flavors/cupcake/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"

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


# phpcs installation
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
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


# phpstan installation
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
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


# psalm installation
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
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


# phplint installation
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
&& composer global config bin-dir --absolute \

# gitleaks installation
Expand Down
18 changes: 12 additions & 6 deletions flavors/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
#############################################################################################
#OTHER__START
# PHP installation
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
&& export GITHUB_AUTH_TOKEN \
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
Expand Down Expand Up @@ -279,19 +281,23 @@ RUN go install github.com/rhysd/actionlint/cmd/actionlint@latest && go clean --c
&& tar xf ${ML_THIRD_PARTY_DIR}/kubeconform-linux-amd64.tar.gz --directory ${ML_THIRD_PARTY_DIR} \
&& mv ${ML_THIRD_PARTY_DIR}/kubeconform /usr/local/bin \
&& rm ${ML_THIRD_PARTY_DIR}/kubeconform-linux-amd64.tar.gz \
&& find ${ML_THIRD_PARTY_DIR} -type f -not -name 'LICENSE*' -delete -o -type d -empty -delete \
&& find ${ML_THIRD_PARTY_DIR} -type f -not -name 'LICENSE*' -delete -o -type d -empty -delete


# phpcs installation
&& phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192 \
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


# phpstan installation
&& phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720 \
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


# psalm installation
&& phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5 \
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


# phplint installation
&& composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
RUN composer global require --ignore-platform-reqs overtrue/phplint ^5.3 \
&& composer global config bin-dir --absolute \

# protolint installation
Expand Down
6 changes: 4 additions & 2 deletions linters/php_psalm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ ENV PATH="/node-deps/node_modules/.bin:${PATH}" \
#############################################################################################
#OTHER__START
# PHP installation
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
RUN --mount=type=secret,id=GITHUB_TOKEN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
&& export GITHUB_AUTH_TOKEN \
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
Expand All @@ -150,7 +152,7 @@ RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
ENV PATH="/root/.composer/vendor/bin:$PATH"

# psalm installation
RUN phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
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


#OTHER__END
Expand Down
10 changes: 6 additions & 4 deletions megalinter/descriptors/php.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ install:
- dpkg
dockerfile:
- |
RUN wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" \
&& export GITHUB_AUTH_TOKEN \
&& wget --tries=5 -q -O phive.phar https://phar.io/releases/phive.phar \
&& wget --tries=5 -q -O phive.phar.asc https://phar.io/releases/phive.phar.asc \
&& PHAR_KEY_ID="0x9D8A98B29B2D5D79" \
&& ( gpg --keyserver keyserver.pgp.com --recv-keys "$PHAR_KEY_ID" \
Expand Down Expand Up @@ -52,7 +54,7 @@ linters:
install:
dockerfile:
- |
RUN phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpcs -g --trust-gpg-keys 31C7E470E2138192
ide:
atom:
- name: linter-phpcs
Expand Down Expand Up @@ -96,7 +98,7 @@ linters:
install:
dockerfile:
- |
RUN phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install phpstan -g --trust-gpg-keys CF1A108D0E7AE720
ide:
idea:
- name: PHPStan / Psalm / Generics
Expand Down Expand Up @@ -130,7 +132,7 @@ linters:
install:
dockerfile:
- |
RUN phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
RUN GITHUB_AUTH_TOKEN="$(cat /run/secrets/GITHUB_TOKEN)" && export GITHUB_AUTH_TOKEN && phive --no-progress install psalm -g --trust-gpg-keys 8A03EA3B385DBAA1,12CE0F1D262429A5
ide:
idea:
- name: PHPStan / Psalm / Generics
Expand Down

0 comments on commit d850e81

Please sign in to comment.