-
Notifications
You must be signed in to change notification settings - Fork 4
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 #4 from jprosenbaum/dockerize-for-github-execution
Dockerize for GitHub execution
- Loading branch information
Showing
10 changed files
with
215 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
template.md.jinja | ||
config.toml | ||
Dockerfile | ||
README.md | ||
|
||
/examples | ||
/.github | ||
/repos | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/config.toml | ||
/shortcut_client | ||
/target | ||
/repos |
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 @@ | ||
FROM rust:1.70-buster as builder | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y jq curl maven | ||
|
||
ENV OPENAPI_GENERATOR_VERSION=6.6.0 | ||
RUN curl "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$OPENAPI_GENERATOR_VERSION/openapi-generator-cli-$OPENAPI_GENERATOR_VERSION.jar" -o /usr/local/lib/openapi-generator.jar | ||
|
||
WORKDIR /usr/src/shortcut_release_helper | ||
COPY --chmod=700 bin/generate_openapi_client.sh bin/cleanup.sh bin/ | ||
COPY --chmod=700 docker/openapi-generator-cli /usr/local/bin/ | ||
COPY Cargo.toml Cargo.lock ./ | ||
COPY shortcut_release_helper ./shortcut_release_helper/ | ||
RUN ./bin/generate_openapi_client.sh | ||
RUN cargo build --release --bin shortcut_release_helper | ||
|
||
|
||
FROM debian:bullseye-slim | ||
RUN apt update \ | ||
&& apt install -y curl jq git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
## GITHUB Actions execution group is 123 while testing, locally it is 1000 | ||
## This is to resolve file ownership issues will running inside a container | ||
RUN groupadd -g 123 schelper \ | ||
&& useradd -m -u 1001 -g schelper schelper | ||
USER schelper | ||
|
||
WORKDIR /src | ||
RUN git config --global --add safe.directory "*" | ||
|
||
CMD ["/script/execute.sh"] | ||
|
||
COPY --chmod=700 docker/execute.sh /script/execute.sh | ||
COPY --from=builder /usr/src/shortcut_release_helper/target/release /usr/local/bin/shortcut_release_helper | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
set -eu | ||
set -o pipefail | ||
set -x | ||
|
||
# Cleanup the generated code to ensure it compiles | ||
|
||
|
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,3 @@ | ||
#!/bin/bash | ||
git config --global --add safe.directory "*" | ||
/usr/local/bin/shortcut_release_helper/shortcut_release_helper RELEASE_NOTES.md |
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,96 @@ | ||
name: 'release-notes-notification' | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
# * is a special character in YAML so you have to quote this string | ||
- cron: '0 9 * * MON,WED,FRI' | ||
|
||
permissions: read-all | ||
|
||
concurrency: | ||
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | ||
cancel-in-progress: true | ||
|
||
env: | ||
RELEASE_NOTES_EMAIL_FROM: ${{ vars.RELEASE_NOTES_EMAIL_FROM }} | ||
RELEASE_NOTES_EMAIL_TO: ${{ vars.RELEASE_NOTES_EMAIL_TO }} | ||
RELEASE_NOTES_EMAIL_SUBJECT: "Release Notes" | ||
|
||
## Using GMAIL smtp relay | ||
MAIL_URL: smtp+starttls://${{env.MAIL_USERNAME}}:${{env.MAIL_PASSWORD}}@${{env.MAIL_SERVER}}:${{env.MAIL_SERVER_PORT}} | ||
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} | ||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} | ||
MAIL_SERVER: "smtp.gmail.com" | ||
MAIL_SERVER_PORT: 465 | ||
|
||
SHORTCUT_TOKEN: ${{ secrets.SHORTCUT_TOKEN }} | ||
SHORTCUT_RELEASE_HELPER_IMAGE: ghcr.io/<username>/<repo>/<image>:<tag> | ||
|
||
jobs: | ||
release-notes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
path: src/repo_one | ||
repository: <REPOSITORY ONE> | ||
token: ${{ secrets.ACTION_PAT_TOKEN }} | ||
fetch-depth: 0 # Needed to pull TAG history | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
path: src/repo_two | ||
repository: <REPOSITORY TWO> | ||
token: ${{ secrets.ACTION_PAT_TOKEN }} | ||
fetch-depth: 0 # Needed to pull TAG history | ||
|
||
- name: Configure | ||
run: | | ||
echo "Coping Jinja template" | ||
cp $GITHUB_WORKSPACE/notifications/template.md.jinja $GITHUB_WORKSPACE/src | ||
echo "Generating config.toml" | ||
echo "api_key = '$SHORTCUT_TOKEN'" > $GITHUB_WORKSPACE/src/config.toml | ||
echo "template_file = 'template.md.jinja'" >> $GITHUB_WORKSPACE/src/config.toml | ||
echo "[repositories]" >> $GITHUB_WORKSPACE/src/config.toml | ||
echo "Fetching Last Release Branch SHAs" | ||
for dir in $GITHUB_WORKSPACE/src/*/ # list directories in the form "/src/dirname/" | ||
do | ||
GIT_RELEASE_SHA="" | ||
dir=${dir%*/} # remove the trailing "/" | ||
dir=$(echo "${dir##*/}") # print everything after the final "/" | ||
## Looks for the last PRODUCTION tag added as the starting point for the release notes | ||
GIT_RELEASE_SHA=$(cd $GITHUB_WORKSPACE/src/$dir && git log --oneline --tags="*production*" --reverse -n 1 --format=%H) | ||
echo "Last Release Branch SHA - $dir - $GIT_RELEASE_SHA" | ||
echo "$dir = { location = '/src/$dir', release_branch = '$GIT_RELEASE_SHA', next_branch = 'main' }" >> $GITHUB_WORKSPACE/src/config.toml | ||
done | ||
- name: Compile | ||
run: | | ||
cd ./src | ||
docker login ghcr.io -u ${{ secrets.ACTION_PAT_USERNAME }} -p ${{ secrets.ACTION_PAT_TOKEN }} | ||
docker run --rm -v $(pwd):/src ${{ env.SHORTCUT_RELEASE_HELPER_IMAGE }} | ||
- name: Send | ||
uses: dawidd6/action-send-mail@v3 | ||
# https://github.com/marketplace/actions/send-email | ||
with: | ||
connection_url: ${{env_MAIL_URL}} | ||
server_address: ${{env.MAIL_SERVER}} | ||
server_port: ${{env.MAIL_SERVER_PORT}} | ||
secure: true | ||
|
||
username: ${{env.MAIL_USERNAME}} | ||
password: ${{env.MAIL_PASSWORD}} | ||
|
||
subject: ${{ env.RELEASE_NOTES_EMAIL_SUBJECT }} | ||
to: ${{ env.RELEASE_NOTES_EMAIL_TO }} | ||
from: ${{ env.RELEASE_NOTES_EMAIL_FROM }} | ||
html_body: file://src/RELEASE_NOTES.md | ||
convert_markdown: true | ||
priority: low |
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,27 @@ | ||
# Stage Release Notes | ||
|
||
compiled on {{ today() }} | ||
|
||
|
||
{%- for story in (stories | split_by_label("Release Notes") | first) %} | ||
* [sc-{{ story.id }}]({{ story.app_url }}) {{ story.name }} | ||
{%- endfor %} | ||
|
||
--- | ||
|
||
## All Stories | ||
|
||
{%- for story in stories %} | ||
* [sc-{{ story.id }}]({{ story.app_url }}) {{ story.name }} | ||
{%- endfor %} | ||
|
||
--- | ||
|
||
## Changes missing story associations | ||
|
||
{%- for commitgroup in unparsed_commits %} | ||
### {{ commitgroup }} | ||
{%- for commit in unparsed_commits[commitgroup] %} | ||
* {{ commit.message | indent(2) }} | ||
{%- endfor %} | ||
{%- endfor %} |
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