diff --git a/.github/workflows/auto-release.yaml b/.github/workflows/auto-release.yaml new file mode 100644 index 0000000..af1a4c2 --- /dev/null +++ b/.github/workflows/auto-release.yaml @@ -0,0 +1,36 @@ +name: Auto-deployment and Upload files to S3 +on: + workflow_dispatch: + push: + branches: + - master +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.8' + - name: Copy 'src' directory into 'app' directory + run: | + cp -R src app + - name: Create 'upload' directory + run: | + mkdir -p upload + - name: Zip 'app' directory into 'upload' directory + run: | + zip -r upload/lambda_function_code.zip app + - name: Copy 'auto-deployment.yaml' to 'upload' directory + run: | + cp aws/auto-deployment.yaml upload + - name: Run python script that empty the S3 bucket and upload files in 'upload' directory to it with public-read + run: | + pip install boto3 + python action/run.py + env: + SOURCE_DIR: upload + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + FOLDER_NAME: ${{ secrets.FOLDER_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/git-secrets.yml b/.github/workflows/git-secrets.yml deleted file mode 100644 index a3dce06..0000000 --- a/.github/workflows/git-secrets.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: git-secrets - -# Controls when the workflow will run -# Triggers the workflow on push or pull request events but only for the main branch -on: [push] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "main" - git-secrets: - # The type of runner that the job will run on - runs-on: ubuntu-18.04 - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - - name: Check Out Source Code - uses: actions/checkout@v2 - - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Installing dependencies - run: - sudo apt-get install git less openssh-server - - name: Installing scanning tool - run: | - brew install git-secrets - git secrets --install - git secrets --register-aws - - name: Running scanning tool - run: - git secrets --scan diff --git a/.github/workflows/workflow.yaml b/.github/workflows/tests.yaml similarity index 55% rename from .github/workflows/workflow.yaml rename to .github/workflows/tests.yaml index 4c6742b..32da533 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/tests.yaml @@ -1,20 +1,20 @@ -name: Automatic tests, code-coverage and auto-deployment files upload to S3 +name: Automatic tests and code-coverage on: - workflow_dispatch: push: branches: - master + pull_request: + branches: + - master + jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' - - name: Copy 'src' directory into 'app' directory - run: | - cp -R src app - name: Add S3 bucket name and aws keys to tests config file run: | sed -i 's/S3_BUCKET_NAME\b/${{ secrets.AWS_S3_BUCKET_TEST }}/1' tests/config.yaml @@ -42,22 +42,3 @@ jobs: if [ $exit_code -eq 1 ]; then exit 1 fi - - name: Create 'upload' directory - run: | - mkdir -p upload - - name: Zip 'app' directory into 'upload' directory - run: | - zip -r upload/lambda_function_code.zip app - - name: Copy 'auto-deployment.yaml' to 'upload' directory - run: | - cp aws/auto-deployment.yaml upload - - name: Run python script that empty the S3 bucket and upload files in 'upload' directory to it with public-read - run: | - pip install boto3 - python action/run.py - env: - SOURCE_DIR: upload - AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} - FOLDER_NAME: ${{ secrets.FOLDER_NAME }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}