Created
August 19, 2022 20:12
-
-
Save rdemoraes/0d819ee1e17997e5e94bf1b1e6da902f to your computer and use it in GitHub Desktop.
github-action-ecs-workflow
This file contains hidden or 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 Amazon ECS | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
- releases | |
pull_request: | |
branches: | |
- main | |
- develop | |
- releases | |
jobs: | |
...[I removed some jobs from here for a better understanding. But I was using some jobs for build javascript dependencies and also building a docker image]... | |
deploy-ecs-dev: | |
name: ECS Task Register | |
runs-on: ubuntu-latest | |
needs: docker_build | |
if: github.ref == 'refs/heads/releases' && github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: nelonoel/[email protected] | |
- uses: nick-invision/persist-action-data@v1 | |
with: | |
data: ${{ steps.build-image.outputs.image }} <----- I removed the step that I built the docker image and | |
retrieve_variables: IMAGE_TAG | |
- 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: us-east-1 | |
- name: Generate task definition file | |
uses: ./.github/actions/generate-task-definition-json | |
with: | |
environment: "dev" | |
ecr_name: ${{ secrets.AWS_ECR_ADDRESS }} | |
ecr_repository_name: "your-ecr-repository-name" | |
image_tag: $IMAGE_TAG | |
container_name: "your-container-name" | |
container_port: 8080 | |
container_cpu: 256 | |
container_memory: 512 | |
host_port: 8080 | |
execution_role_arn: ${{ secrets.DEV_ECS_EXECUTION_ROLE_ARN }} | |
app_datasource_password: ${{ secrets.DEV_APP_DATASOURCE_PASSWD }} | |
app_datasource_url: ${{ secrets.DEV_APP_DATASOURCE_URL }} | |
app_datasource_username: ${{ secrets.DEV_APP_DATASOURCE_USERNAME }} | |
- run: cat task-definition.json <---- just an step for showing the content of the json file created by my own action | |
- name: Deploy Amazon ECS task definition 0 DEV | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
cluster: my-ecs-cluster-name | |
task-definition: task-definition.json <----- that one that my custom action created | |
service: my-ecs-service-name | |
wait-for-service-stability: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment