From f9a60d6fa4b318ed770ed6d6b24c0c0cb7543917 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Wed, 27 Nov 2024 11:22:24 -0500 Subject: [PATCH] add deploy and branch enforcement --- .github/workflows/enforcer.yml | 16 ++++++++++++++++ .github/workflows/push_s3.yml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/enforcer.yml create mode 100644 .github/workflows/push_s3.yml diff --git a/.github/workflows/enforcer.yml b/.github/workflows/enforcer.yml new file mode 100644 index 0000000..2e0ad50 --- /dev/null +++ b/.github/workflows/enforcer.yml @@ -0,0 +1,16 @@ +name: 'Check Branch' + +on: + pull_request: + branches: + - base + +jobs: + check_branch: + runs-on: ubuntu-latest + steps: + - name: Check branch + if: github.head_ref != 'development' + run: | + echo "ERROR: You can only merge to base from the development branch." + exit 1 \ No newline at end of file diff --git a/.github/workflows/push_s3.yml b/.github/workflows/push_s3.yml new file mode 100644 index 0000000..7d7525f --- /dev/null +++ b/.github/workflows/push_s3.yml @@ -0,0 +1,34 @@ +name: Push to S3 + +on: + push: + branches: + - base + - development + +jobs: + push: + runs-on: ubuntu-latest + environment: + name: ${{ github.ref_name }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + role-to-assume: ${{ secrets.AWS_S3_ROLE }} + aws-region: us-east-1 + role-skip-session-tagging: true + + - name: Sync to AWS + run: | + aws s3 sync . s3://${{ secrets.S3_BUCKET_NAME }}/digitized_image_pipeline \ + --exclude '.git/*' \ + --exclude '.github/*' \ + --exclude 'README.md' \ + --exclude 'LICENSE' \ + --exclude '.DS_Store'