mirror of
https://github.com/actions/attest-build-provenance.git
synced 2026-05-13 08:20:57 +00:00
Create aws-workflow-setup
git add .github/workflows/aws.yml git commit -m "Create aws.yml Initial AWS deployment workflow for property listing automation. - Configures GitHub Actions runner on ubuntu-22.04 - Integrates with AWS CLI for S3, Lambda, and EventBridge - Sets up environment variables for Stripe + CRM integration - Includes manual and push triggers"
This commit is contained in:
parent
e4282a2f9d
commit
e40a62a898
95
.github/workflows/aws-workflow-setup
vendored
Normal file
95
.github/workflows/aws-workflow-setup
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
name: Deploy to Amazon ECS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: "Choose environment to deploy"
|
||||
required: true
|
||||
default: "staging"
|
||||
type: choice
|
||||
options:
|
||||
- staging
|
||||
- production
|
||||
|
||||
env:
|
||||
AWS_REGION: us-east-2
|
||||
ECR_REPOSITORY: property-listings
|
||||
ECS_TASK_DEFINITION: .aws/task-definition.json
|
||||
CONTAINER_NAME: property-api
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy to ECS
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set environment-specific vars
|
||||
id: set-env
|
||||
run: |
|
||||
if [[ "${{ github.event.inputs.environment }}" == "production" || "${{ github.ref }}" == "refs/heads/main" ]]; then
|
||||
echo "ECS_CLUSTER=property-cluster-prod" >> $GITHUB_ENV
|
||||
echo "ECS_SERVICE=property-api-service-prod" >> $GITHUB_ENV
|
||||
echo "SLACK_CHANNEL=#deployments-prod" >> $GITHUB_ENV
|
||||
else
|
||||
echo "ECS_CLUSTER=property-cluster-staging" >> $GITHUB_ENV
|
||||
echo "ECS_SERVICE=property-api-service-staging" >> $GITHUB_ENV
|
||||
echo "SLACK_CHANNEL=#deployments-staging" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ env.AWS_REGION }}
|
||||
|
||||
- name: Login to Amazon ECR
|
||||
id: login-ecr
|
||||
uses: aws-actions/amazon-ecr-login@v1
|
||||
|
||||
- name: Build, tag, and push image to Amazon ECR
|
||||
id: build-image
|
||||
env:
|
||||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
||||
IMAGE_TAG: ${{ github.sha }}
|
||||
run: |
|
||||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
||||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
||||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- 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.ECS_TASK_DEFINITION }}
|
||||
container-name: ${{ env.CONTAINER_NAME }}
|
||||
image: ${{ steps.build-image.outputs.image }}
|
||||
|
||||
- name: Deploy Amazon ECS task definition
|
||||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
|
||||
with:
|
||||
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
||||
service: ${{ env.ECS_SERVICE }}
|
||||
cluster: ${{ env.ECS_CLUSTER }}
|
||||
wait-for-service-stability: true
|
||||
|
||||
- name: Slack notification
|
||||
if: always()
|
||||
uses: slackapi/slack-github-action@v1.27.0
|
||||
with:
|
||||
payload: |
|
||||
{
|
||||
"channel": "${{ env.SLACK_CHANNEL }}",
|
||||
"text": ":rocket: ECS Deploy *${{ github.event.inputs.environment || 'production' }}* completed for commit <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}> - Status: ${{ job.status }}"
|
||||
}
|
||||
env:
|
||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||
Loading…
Reference in New Issue
Block a user