This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
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 #256 from aws-solutions/morjoan-dev
Morjoan dev
- Loading branch information
Showing
23 changed files
with
157 additions
and
79 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,61 @@ | ||
name: Send Artifacts Workflow | ||
env: | ||
REGION: us-east-1 | ||
on: | ||
workflow_run: | ||
workflows: ["Push Workflow"] | ||
types: [completed] | ||
jobs: | ||
notify-job: | ||
runs-on: ubuntu-latest | ||
name: Send workflow information to endpoint | ||
environment: notify_env | ||
permissions: | ||
id-token: write | ||
contents: read | ||
actions: read | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install required system packages | ||
run: | | ||
pip install --upgrade --force-reinstall -r deployment/requirements.txt 2> error.txt | ||
if [ -s error.txt ]; then | ||
echo "ERROR: System package installation failed." | ||
cat error.txt | ||
exit 1 | ||
fi | ||
- name: Set up environment variables | ||
run: | | ||
export WORKFLOW_RUN_ID=${{ github.event.workflow_run.id }} | ||
export COMMIT_ID=${{ github.event.workflow_run.head_sha }} | ||
export BRANCH=${{ github.event.workflow_run.head_branch }} | ||
export WORKFLOW_NAME="${{ github.event.workflow_run.name }}" | ||
export NOTIFICATION_ENDPOINT=${{ secrets.ENDPOINT }} | ||
export VERSION=${{ secrets.VERSION }} | ||
echo WORKFLOW_RUN_ID=$WORKFLOW_RUN_ID >> $GITHUB_ENV | ||
echo COMMIT_ID=$COMMIT_ID >> $GITHUB_ENV | ||
echo NOTIFICATION_ENDPOINT=$NOTIFICATION_ENDPOINT >> $GITHUB_ENV | ||
echo BRANCH=$BRANCH >> $GITHUB_ENV | ||
echo WORKFLOW_NAME=$WORKFLOW_NAME >> $GITHUB_ENV | ||
echo VERSION=$VERSION >> $GITHUB_ENV | ||
- name: Determine pipeline type | ||
run: | | ||
if [ $BRANCH == "main" ]; then | ||
export PIPELINE_TYPE="release" | ||
else | ||
export PIPELINE_TYPE="feature" | ||
fi | ||
echo PIPELINE_TYPE=$PIPELINE_TYPE >> $GITHUB_ENV | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
role-to-assume: ${{ secrets.NOTIFY_ROLE }} | ||
aws-region: ${{ env.REGION }} | ||
role-duration-seconds: 900 | ||
- name: Invoke endpoint | ||
run: | | ||
cd deployment | ||
python end-workflow-notification.py |
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
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,39 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
""" | ||
This module sends notification about the end of a workflow run | ||
and its associated artifacts. | ||
""" | ||
|
||
import os | ||
import requests | ||
from aws_requests_auth.boto_utils import BotoAWSRequestsAuth | ||
from urllib.parse import urlparse | ||
|
||
API_REGION = os.environ.get('AWS_DEFAULT_REGION') | ||
NOTIFICATION_ENDPOINT = os.environ.get('NOTIFICATION_ENDPOINT') | ||
|
||
PAYLOAD = {} | ||
PAYLOAD['solution_name'] = os.environ.get('GITHUB_REPOSITORY').split('/')[1] | ||
PAYLOAD['branch'] = os.environ.get('BRANCH') | ||
PAYLOAD['workflow_name'] = os.environ.get('WORKFLOW_NAME') | ||
PAYLOAD['commit_id'] = os.environ.get('COMMIT_ID') | ||
PAYLOAD['workflow_run_id'] = os.environ.get('WORKFLOW_RUN_ID') | ||
PAYLOAD['version'] = os.environ.get('VERSION') | ||
PAYLOAD['pipeline_type'] = os.environ.get('PIPELINE_TYPE') | ||
def main(): | ||
parsed = urlparse(NOTIFICATION_ENDPOINT) | ||
auth = BotoAWSRequestsAuth(aws_host=parsed.netloc, | ||
aws_region=API_REGION, | ||
aws_service='execute-api') | ||
print(PAYLOAD) | ||
response = requests.post(NOTIFICATION_ENDPOINT, json=PAYLOAD, auth=auth, timeout=25) | ||
print(response.text) | ||
if response.status_code != 200: | ||
return 1 | ||
else: | ||
return 0 | ||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ pylint | |
requests | ||
stringcase | ||
testresources | ||
aws-requests-auth |
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
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
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
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
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
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
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
Oops, something went wrong.