-
Notifications
You must be signed in to change notification settings - Fork 243
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 #109 from flo-kn/feat/workflowToAutomateSignatureC…
…reation gh workflow for automated signature creation and example on storing in s3 bucket
- Loading branch information
Showing
6 changed files
with
172 additions
and
1 deletion.
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,47 @@ | ||
name: Generate eMail Template | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
generate-email-signature: | ||
name: Generate eMail Signature | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# Ignore validation error - this line is necessary | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 18.x | ||
- name: Populate conf.json | ||
working-directory: templates/${{ env.THEME }} | ||
env: | ||
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }} | ||
MOBILE_PHONE_COUNTRY_CODE: ${{ secrets.MOBILE_PHONE_COUNTRY_CODE }} | ||
MOBILE_PHONE_NUMBER: ${{ secrets.MOBILE_PHONE_NUMBER }} | ||
THEME: dark | ||
run: | | ||
npm run generate:conf ${{ env.THEME }} | ||
- name: Install NPM and Generate Signature | ||
run: | | ||
npm -v | ||
node -v | ||
npm install | ||
npm run once | ||
- name: configure aws credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.GH_GENERATE_EMAIL_ROLE }} | ||
aws-region: eu-central-1 | ||
- name: Upload Signature to S3 | ||
env: | ||
bucket_name: ${{ secrets.BUCKET_NAME }} | ||
local_source_dir: './dist' | ||
remote_dir: generated-email-signatures | ||
run: | | ||
aws s3 cp --recursive $local_source_dir s3://$bucket_name/$remote_dir |
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,7 @@ | ||
HOST=$(curl https://token.actions.githubusercontent.com/.well-known/openid-configuration | jq -r '.jwks_uri | split("/")[2]') | ||
|
||
echo | openssl s_client -servername $HOST -showcerts -connect $HOST:443 2> /dev/null \ | ||
| sed -n -e '/BEGIN/h' -e '/BEGIN/,/END/H' -e '$x' -e '$p' | tail +2 \ | ||
| openssl x509 -fingerprint -noout \ | ||
| sed -e "s/.*=//" -e "s/://g" \ | ||
| tr "ABCDEF" "abcdef" |
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,65 @@ | ||
Parameters: | ||
GitHubOrg: | ||
Type: String | ||
Default: <YourGitHubOrg||YourGitHubUsername> | ||
RepoName: | ||
Type: String | ||
Default: <YourRepoName> | ||
OIDCProviderArn: | ||
Description: Arn for the GitHub OIDC Provider. | ||
Default: "" | ||
Type: String | ||
|
||
Conditions: | ||
CreateOIDCProvider: !Equals | ||
- !Ref OIDCProviderArn | ||
- "" | ||
|
||
Resources: | ||
Role: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
RoleName: GithubGenerateEmailRole | ||
Policies: | ||
- PolicyName: GithubGenerateEmailRolePolicy | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Action: | ||
- s3:PutObject | ||
- s3:PutObjectAcl | ||
- s3:GetObject | ||
- s3:GetObjectAcl | ||
- s3:AbortMultipartUpload | ||
Resource: | ||
- arn:aws:s3:::<BucketName> | ||
- arn:aws:s3:::<BucketName>/* | ||
Effect: Allow | ||
AssumeRolePolicyDocument: | ||
Statement: | ||
- Effect: Allow | ||
Sid: "GithubOIDC" | ||
Action: sts:AssumeRoleWithWebIdentity | ||
Principal: | ||
Federated: !If | ||
- CreateOIDCProvider | ||
- !Ref GithubOidc | ||
- !Ref OIDCProviderArn | ||
Condition: | ||
StringLike: | ||
token.actions.githubusercontent.com:sub: !Sub repo:${GitHubOrg}/${RepoName}:* | ||
|
||
|
||
GithubOidc: | ||
Type: AWS::IAM::OIDCProvider | ||
Condition: CreateOIDCProvider | ||
Properties: | ||
Url: https://token.actions.githubusercontent.com | ||
ClientIdList: | ||
- sts.amazonaws.com | ||
ThumbprintList: | ||
- 6938fd4d98bab03faadb97b34396831e3780aea1 | ||
|
||
Outputs: | ||
Role: | ||
Value: !GetAtt Role.Arn |
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,25 @@ | ||
#!bin/sh | ||
|
||
# script for dynamic interactive creation of conf.json file | ||
|
||
# If variable not set or null, set to some exemplary defaults. | ||
theme="${1:-light}" | ||
mobile_phone_country_code="${2:-45}" | ||
mobile_phone_number="${3:-80100100}" | ||
email_address="${4:-info@${theme}.dk}" | ||
|
||
echo $theme | ||
|
||
conf_file_path="./templates/$theme/conf.json" | ||
touch $conf_file_path | ||
echo { > $conf_file_path | ||
echo "\"id"\": "\"$theme"\", >> $conf_file_path | ||
echo "\"signature"\": "\"Best regards,"\", >> $conf_file_path | ||
echo "\"name"\": "\"The $theme mail team"\", >> $conf_file_path | ||
echo "\"contactMain"\": "\"Call <a href='tel:00$mobile_phone_country_code$mobile_phone_number'><span>($mobile_phone_country_code) $mobile_phone_number</span></a> or email us at"\", >> $conf_file_path | ||
echo "\"contactMail"\": "\"$email_address"\", >> $conf_file_path | ||
echo "\"slogan"\": "\"LED Pylon. LED Wall. Digital Signage."\", >> $conf_file_path | ||
echo "\"logoUrl"\": "\"/assets/$theme.png"\", >> $conf_file_path | ||
echo "\"logoAlt"\": "\"$theme logo"\", >> $conf_file_path | ||
echo "\"website"\": "\"http://$theme.dk"\" >> $conf_file_path | ||
echo } >> $conf_file_path |
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