-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from voxpupuli/slack
feat: Add RocketChat notification script and a way to add additional ca certificates
- Loading branch information
Showing
5 changed files
with
188 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,17 +18,30 @@ LABEL org.label-schema.maintainer="Voxpupuli Team <[email protected]>" \ | |
org.label-schema.schema-version="1.0" \ | ||
org.label-schema.dockerfile="/Dockerfile" | ||
|
||
RUN apk update && apk upgrade \ | ||
&& apk add --no-cache --update git git-lfs openssh-client bash | ||
|
||
COPY Dockerfile / | ||
COPY docker-entrypoint.sh / | ||
COPY docker-entrypoint.d /docker-entrypoint.d | ||
COPY scripts /scripts | ||
COPY --from=build /npm /npm | ||
|
||
RUN apk update && apk upgrade \ | ||
&& apk add --no-cache --update git git-lfs openssh-client bash jq curl \ | ||
&& chmod +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh | ||
|
||
# fix ENOGITREPO Not running from a git repository. | ||
RUN git config --global --add safe.directory '*' | ||
|
||
WORKDIR /data | ||
|
||
ENV CERT_JSON="" | ||
ENV PATH="$PATH:/npm/node_modules/.bin" | ||
ENTRYPOINT [ "semantic-release" ] | ||
ENV NODE_OPTIONS="--use-openssl-ca" | ||
|
||
# The CI_* are empty, because docker does not know about them on build time. | ||
ENV ROCKETCHAT_EMOJI=":tada:" | ||
ENV ROCKETCHAT_MESSAGE_TEXT="A new tag for the project ${CI_PROJECT_NAME} was created by ${CI_COMMIT_AUTHOR}." | ||
Check warning on line 42 in Dockerfile GitHub Actions / build-and-push-containerVariables should be defined before their use
|
||
ENV ROCKETCHAT_HOOK_URL="https://rocketchat.example.com/hooks/here_be_dragons" | ||
ENV ROCKETCHAT_TAGS_URL="${CI_PROJECT_URL}/-/tags" | ||
|
||
ENTRYPOINT [ "/docker-entrypoint.sh" ] | ||
CMD [ "--dry-run" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# | ||
# @summary If you somehow need own certificates inside the container. | ||
# | ||
# @example | ||
# you want to run the slack webhook on a target with an internal ca certificate. | ||
# export the CERT_JSON on container run and it should be imported with this script. | ||
# it is expected that the certificate is a json hash of PEM certificates. | ||
# | ||
# {"certificates":{"root_ca":"-----BEGIN CERTIFICATE-----\n...","signing_ca":"-----BEGIN CERTIFICATE-----\n..."}} | ||
# | ||
if [ -n "${CERT_JSON}" ]; then | ||
for key in $(echo "${CERT_JSON}" | jq -r '.certificates | keys[]'); do | ||
cert=$(echo "${CERT_JSON}" | jq -r ".certificates[\"$key\"]") | ||
printf "%s" "${cert}" > /usr/local/share/ca-certificates/${HOSTNAME}-${key}.pem | ||
echo "INFO: imported ${key}" | ||
done | ||
|
||
update-ca-certificates | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# bash is required to pass ENV vars with dots as sh cannot do this | ||
|
||
set -e | ||
|
||
for f in /docker-entrypoint.d/*.sh; do | ||
echo "INFO: Running $f" | ||
"$f" | ||
done | ||
|
||
exec /npm/node_modules/.bin/semantic-release "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
while getopts V:o:d flag | ||
do | ||
case "${flag}" in | ||
V) VERSION=${OPTARG};; | ||
o) OPTIONS=${OPTARG};; | ||
d) DEBUG=1;; | ||
esac | ||
done | ||
|
||
payload="{ | ||
\"emoji\": \"${ROCKETCHAT_EMOJI}\", | ||
\"text\": \"${ROCKETCHAT_MESSAGE_TEXT}\", | ||
\"attachments\": [ | ||
{ | ||
\"title\": \"Release ${VERSION}\", | ||
\"title_link\": \"${ROCKETCHAT_TAGS_URL}/${VERSION}\" | ||
} | ||
] | ||
}" | ||
|
||
if [ "${DEBUG}" == 1 ]; then | ||
echo "Version is: ${VERSION}" | ||
echo "Options are: ${OPTIONS}" | ||
echo "Payload is:" | ||
echo "${payload}" | ||
fi | ||
|
||
if [[ -n ${ROCKETCHAT_HOOK_URL} ]]; then | ||
curl \ | ||
-X POST \ | ||
-H 'Content-Type: application/json' \ | ||
--data "${payload}" \ | ||
${OPTIONS} ${ROCKETCHAT_HOOK_URL} | ||
fi |