Skip to content

Commit

Permalink
Merge pull request #13 from 0xPolygon/DEVOPS-2759-repo-public-update
Browse files Browse the repository at this point in the history
Devops 2759 repo public update
  • Loading branch information
sshrihar authored Apr 26, 2024
2 parents a514c53 + 9ea7ced commit 911b8f0
Show file tree
Hide file tree
Showing 15 changed files with 489 additions and 404 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 0 additions & 2 deletions .github/CODEOWNERS

This file was deleted.

41 changes: 0 additions & 41 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

26 changes: 0 additions & 26 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

16 changes: 1 addition & 15 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,16 @@ Please delete options that are not relevant.
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.

- [ ] Test A
- [ ] Test B

## Checklist:

Before you submit your pull request, please make sure you have completed the following:

- [ ] I have followed the [contributing guidelines](CONTRIBUTING.md).
- [ ] My code follows the style guidelines of this project and I have run `lint` to ensure the code style is valid
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes

## Screenshots (if appropriate):

Include any screenshots that will help explain your changes.

## Additional context

Add any other context about the pull request here.
Add any other context about the pull request here.
77 changes: 55 additions & 22 deletions .github/workflows/ecs_deploy_docker_taskdef.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
on:
workflow_call:
inputs:
app_name:
required: true
type: string
account_number:
required: true
type: string
docker_file:
app_name:
required: true
type: string
cluster_name:
Expand All @@ -16,13 +13,20 @@ on:
taskdef_file_vars:
required: true
type: string
description: "Taskdef file variables passed from the app repository or use the local"
docker_file:
required: false
type: string
default: Dockerfile
taskdef_file_script:
required: false
default: ".github/taskdefinition_template/taskdef_creator.py"
default: "local"
description: "Python script to handle task definition creation handling"
type: string
taskdef_file_template:
required: false
default: ".github/taskdefinition_template/taskdef_template.json"
default: "local"
description: "Taskdef file template passed from the app repository or use the local"
type: string
aws_region:
required: false
Expand All @@ -32,6 +36,7 @@ on:
required: false
default: "staging"
type: string


jobs:
deploy_workflow:
Expand All @@ -42,24 +47,54 @@ jobs:
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout Support directory
if: ${{ inputs.taskdef_file_script }} == "local"
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: 0xPolygon/pipelines
ref: DEVOPS-2759-repo-public-update
path: ./pipelines
sparse-checkout: |
Support/
- name: Checkout Code Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
path: ./code

- name: Set variables
run: |
if [ "${{ inputs.taskdef_file_script }}" == "local" ]; then
echo "taskdef_file_script=pipelines/Support/taskdef_template/taskdef_creator.py" >> $GITHUB_ENV
echo "taskdef_file_template=pipelines/Support/taskdef_template/taskdef_template.json" >> $GITHUB_ENV
else
echo "taskdef_file_script=${{inputs.taskdef_file_script}}" >> $GITHUB_ENV
echo "taskdef_file_template=${{inputs.taskdef_file_template}}" >> $GITHUB_ENV
fi
- name: Create taskdef file dynamically using parameters passed
run: |
ls -lrt
export PIPENV_PIPFILE=.github/taskdefinition_template/Pipfile
python -m pip install --upgrade pip && \
pip install pipenv && \
pipenv install && \
pipenv run python ${{ inputs.taskdef_file_script }} \
${{ inputs.taskdef_file_vars }} ${{ inputs.taskdef_file_template }}
script_dir="$(dirname ${{ env.taskdef_file_script }})"
if [[ -z "$script_dir" ]]; then
echo "Warning: Script name doesn't contain a directory path. Using current directory."
script_dir="."
fi
export PIPENV_PIPFILE=$script_dir/Pipfile
python -m pip install --upgrade pip
pip install pipenv
pipenv install
pipenv run python ${{ env.taskdef_file_script }} \
-pf code/${{ inputs.taskdef_file_vars }} -tt ${{ env.taskdef_file_template }} \
-acc ${{ inputs.account_number }} -app ${{ inputs.app_name }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ inputs.aws_region }}
role-to-assume: arn:aws:iam::${{ inputs.account_number }}:role/${{ inputs.app_name }}-GithubActionsRole
role-to-assume: |
arn:aws:iam::${{ inputs.account_number }}:role/${{ inputs.app_name }}-GithubActionsRole
role-session-name: GithubActionsSession

- name: Login to Amazon ECR
Expand All @@ -73,6 +108,7 @@ jobs:
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: ${{ inputs.app_name }}-ecr
run: |
cd code
current_dir=$(realpath .)
target_dir=$(dirname "$(realpath "${{ inputs.docker_file }}")")
if [[ "$current_dir" != "$target_dir" ]]; then
Expand All @@ -83,19 +119,16 @@ jobs:
fi
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f $docker_file_basename .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Extract directory path
run: |
echo "TASKDEF_FILE=$(dirname "${{ inputs.taskdef_file_template }}")/${{ inputs.app_name }}.json" >> $GITHUB_ENV
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV
echo "TASKDEF_FILE=$(dirname "${{ env.taskdef_file_template }}")/${{ inputs.app_name }}.json" >> $GITHUB_ENV
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: "${{ env.TASKDEF_FILE }}"
container-name: ${{ inputs.app_name }}
image: ${{ steps.build-image.outputs.image }}
image: ${{ env.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.vscode/*
.vscode/*
*.pyc
75 changes: 5 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,7 @@
<!-- PROJECT SHIELDS -->
![Build][Build-badge]
[![Coverage][Coverage-badge]][Sonar-url]
[![Vulnerabilities][Vulnerability-badge]][Sonar-url]
# Pipelines

# 0xPolygon Pipelines
This repo serves as the repository for shared pipelines across the Polygon organization. To learn more about using
shared pipelines, please see the [Shared Pipelines Documentation](https://docs.github.com/en/actions/creating-actions/sharing-actions-and-workflows-with-your-organization).
Supports github workflow pipelines by providing solutions for build pipelines by tracking common workflows.
The workflow are executed through passing required parameters.

### Built With

![Static Badge](https://img.shields.io/badge/alcohol-sarcasm-8A2BE2?logo=polygon)

## Getting Started

### Local Development

## Usage

To use this workflow, provide the required inputs when triggering the workflow run. Ensure that the necessary secrets and permissions are configured in your GitHub repository for GCP authentication and Docker image pushing.

steps:
- id: gcp-build-action
uses: 0xPolygon/pipelines@v1
with:
workload_identity_provider: ${{ env.WIF_PROVIDER }}
service_account: ${{ env.WIF_SERVICE_ACCOUNT }}
gar_location: ${{ env.GAR_LOCATION }}
docker_image: ${{ env.IMAGE_NAME }}
dockerfile_name: Dockerfile
dockerfile_path: .
critical_count: ${{ env.CRITICAL_COUNT }}
helm_values_path: './helm-chart/values.yaml'
attestor: ${{ env.ATTESTOR }}
attestor_project: ${{ env.ATTESTOR_PROJECT_ID }}
keyversion_project: ${{ env.ATTESTOR_PROJECT_ID }}
keyversion_location: ${{ env.GAR_LOCATION }}
keyversion_keyring: ${{ env.KEY_RING }}
keyversion_key: ${{ env.KEY }}

Read more info: [gcp-build-pipeline](/docs/gcp-build-pipeline.md)

## Contributing

This is the place to document your delivery workflow. For example:

1. Clone the project
2. Create a feature branch beginning with the ticket number (`git checkout -b INC-7689/update-readme`)
3. Commit your changes (`git commit -m 'Update README.me with default template`)
4. Push to the branch (`git push origin INC-7689/update-readme`)
5. Open a Pull Request
6. After review and approval, changes are deployed immediately

## Contact

![Email][Email-badge]
![Slack][Slack-badge]


<!-- MARKDOWN LINKS AND IMAGES (update/replace as needed for your application) -->
[Build-badge]: https://github.com/0xPolygon/learn-api/actions/workflows/main.yml/badge.svg
[Coverage-badge]: https://sonarqube.polygon.technology/api/project_badges/measure?project=TODO
[Vulnerability-badge]: https://sonarqube.polygon.technology/api/project_badges/measure?project=TODO
[Sonar-url]: https://sonarqube.polygon.technology/dashboard?id=TODO
[Language-badge]: https://img.shields.io/badge/Nodejs-18.0-informational
[Language-url]: https://nodejs.org/en
[Email-badge]: https://img.shields.io/badge/[email protected]?logo=gmail
[Slack-badge]: https://img.shields.io/badge/Slack-team_devops-informational?logo=slack
[Production-badge]: https://img.shields.io/badge/Production_URL-polygon.technology-informational
[Production-url]: https://link.to/prod
[Staging-badge]: https://img.shields.io/badge/Staging_URL-staging.polygon.technology-informational
[Staging-url]: https://link.to/staging
## Support
Support folder tracks scripts that can be used to support the execution workflow for github pipelines.
7 changes: 7 additions & 0 deletions Support/taskdef_template/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
pyyaml = "6.0.1"
Loading

0 comments on commit 911b8f0

Please sign in to comment.