diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..035370ac --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Deploy + +on: + release: + types: + - published + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-22.04 + + environment: AWS_ACCESS_KEY_ID + env: + READ_PRIVATE_SUBMODULE_TOKEN: ${{ secrets.READ_PRIVATE_SUBMODULE_TOKEN }} + + WORKING_DIRECTORY: ${{ vars.DEPLOY_WORKING_DIRECTORY }} + + DEPLOY_FILENAME: ${{ vars.DEPLOY_FILENAME }} + S3_REGION: ${{ vars.S3_REGION }} + + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + submodules: true + token: ${{ env.READ_PRIVATE_SUBMODULE_TOKEN }} + + - name: Install AWS cli + run: | + sudo apt-get update + sudo apt-get install awscli + + - name: Deploy code to AWS S3 + run: | + zip -r ${{ env.DEPLOY_FILENAME }} appspec.yml app env deploy-script + aws s3 cp ${{ env.DEPLOY_FILENAME }} s3://stat-ec2-app-code-deploy-bucket/${{ env.DEPLOY_FILENAME }} --region ${{ env.S3_REGION }} + working-directory: ${{ env.DEPLOY_WORKING_DIRECTORY }}