Deploy to AWS CodeDeploy #4
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
name: Deploy to AWS CodeDeploy | |
on: | |
# push: | |
# branches: | |
# - main | |
workflow_dispatch: | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
deploy: | |
environment: development-direct | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup ENV File | |
run: | | |
cat << 'EOF' > .env | |
${{ secrets.ENV_FILE }} | |
EOF | |
- name: Package repo | |
run: | | |
zip -r deployment.zip . | |
# Step 3: Configure AWS credentials for subsequent AWS CLI commands. | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: ${{ vars.AWS_REGION }} | |
role-to-assume: ${{ vars.AWS_ACTIONS_ROLE_ARN }} | |
role-session-name: atlascodedeploysession | |
# Step 4: Upload the deployment artifact (ZIP file) to S3. | |
- name: Upload artifact to S3 | |
run: | | |
aws s3 cp deployment.zip s3://${{ vars.CODEDEPLOY_S3_BUCKET }}/deployment.zip | |
# Step 5: Create a new deployment in CodeDeploy. | |
- name: Create CodeDeploy Deployment | |
run: | | |
aws deploy create-deployment \ | |
--application-name "${{ vars.CODEDEPLOY_APPLICATION_NAME }}" \ | |
--deployment-group-name "${{ vars.CODEDEPLOY_DEPLOYMENT_GROUP }}" \ | |
--s3-location bucket=${{ vars.CODEDEPLOY_S3_BUCKET }},key=deployment.zip,bundleType=zip \ | |
--region "${{ vars.AWS_REGION }}" |