Coder Social home page Coder Social logo

11bluetree / github-action-aws-ecs-run-task Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geekcell/github-action-aws-ecs-run-task

0.0 0.0 0.0 4.33 MB

Run an AWS ECS Fargate task.

Home Page: https://www.geekcell.io

License: Apache License 2.0

JavaScript 100.00%

github-action-aws-ecs-run-task's Introduction

Description

Run an AWS ECS Fargate task and execute a custom command. See the log output of the command that is executed.

Details

This action makes it possible to run an AWS ECS Fargate task and execute custom commands. If the task definition is configured to log to CloudWatch, this action will try to tail the output of container, providing instant feedback inside the GitHub Workflow.

This action is great for executing migrations or other pre/post deployment steps for ECS Fargate applications.

Usage

Full example

- name: Execute migrations and seeders
  id: run-task
  uses: 11bluetree/[email protected]
  with:
    cluster: application-cluster
    task-definition: application-task-def
    assign-public-ip: 'DISABLED'

    subnet-ids: |
      subnet-04f133a104b9e95df
      subnet-0dc419ee6a1483514

    security-group-ids: |
      sg-123456789101112
      sg-112398765421333

    tail-logs: true
    override-container: app
    override-container-command: |
      /bin/sh
      -c
      php artisan migrate --force --ansi && php artisan db:seed --force --ansi
    override-container-environment: |
      AWS_REGION=us-east-1
      FOO=baz

Minimal example

- name: Run migration container
  id: run-task
  uses: 11bluetree/[email protected]
  with:
    cluster: application-cluster
    task-definition: application-task-def
    subnet-ids: subnet-04f133a104b9e95df
    security-group-ids: sg-123456789101112

Appending multiple lines into a single command

You can use the backslash character \ to append multiple lines into a single line. This is useful if you have many commands to execute and want to keep the YAML file readable. Otherwise, each line will be passed to the AWS ECS Fargate task as a separate argument.

Note: Make sure to use the | character so the YAML parser interprets the value as a multiline string. You can read more about this in the YAML documentation.

For example:

...
override-container-command: |
  /bin/sh
  -c
  php artisan down && \
  php artisan migrate --force --ansi && \
  php artisan db:seed --force --ansi && \
  php artisan cache:clear --ansi

Will pass the following command to the container on the AWS ECS Fargate task:

["sh", "-c", "php artisan down && php artisan migrate --force --ansi && php artisan db:seed --force --ansi && php artisan cache:clear --ansi"]

Inputs

parameter description required default
task-definition The name or the ARN of the task definition to use for the task. true
subnet-ids The list of subnet IDs for the task to use. If multiple they should be passed as multiline argument with one subnet ID per line. true
security-group-ids List of security group IDs for the task. If multiple they should be passed as multiline argument with one subnet ID per line. true
assign-public-ip Assign public a IP to the task. Options: ['ENABLED', 'DISABLED'] false DISABLED
cluster Which ECS cluster to start the task in. false
override-container Will use containerOverrides to run a custom command on the container. If provided, override-container-command must also be set. false
override-container-command The command to run on the container if override-container is passed. false
override-container-environment Add or override existing environment variables if override-container is passed. Provide one per line in key=value format. false
tail-logs If set to true, will try to extract the logConfiguration for the first container in the task definition. If override-container is passed, it will extract the logConfiguration from that container. Tailing logs is only possible if the provided container uses the awslogs logDriver. false true
task-stopped-wait-for-max-attempts How many times to check if the task is stopped before failing the action. The delay between each check is 6 seconds. false 100

Outputs

parameter description
task-arn The full ARN for the task that was ran.
task-id The ID for the task that was ran.
log-output The log output of the task that was ran, if tail-logs was set to true.

Runs

This action is a node20 action.

github-action-aws-ecs-run-task's People

Contributors

ic3w0lf avatar dependabot[bot] avatar 11bluetree avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.