From 0f787e4eeb1946592b8ea2d3b39a675de5c2577a Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Thu, 14 Mar 2024 18:23:06 -0400 Subject: [PATCH 1/5] Convert to Actions --- .github/workflows/build-and-publish.yml | 40 +++++++++++++++++++++++++ README.md | 2 +- action-services.yml | 10 +++++++ codeship-services.yml | 6 ---- codeship-steps.yml | 21 ------------- dockercfg.encrypted | 2 -- 6 files changed, 51 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/build-and-publish.yml create mode 100644 action-services.yml delete mode 100644 codeship-services.yml delete mode 100644 codeship-steps.yml delete mode 100644 dockercfg.encrypted diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..02fe580 --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,40 @@ +name: Build and Publish + +on: + push: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run tests + run: docker-compose -f action-services.yml run test + + build-and-publish: + name: Build and Publish + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.DOCKER_ORG }}/ecs-deploy + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index b44564d..26bab16 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ecs-deploy ================= -[ ![Codeship Status for silinternational/ecs-deploy](https://app.codeship.com/projects/393a91e0-da8d-0134-6603-1e487e818871/status?branch=master)](https://app.codeship.com/projects/203720) +![Status for silinternational/ecs-deploy](https://github.com/silinternational/ecs-deploy/actions/workflows/build-and-deploy.yml/badge.svg?branch=master) This script uses the Task Definition and Service entities in Amazon's ECS to instigate an automatic blue/green deployment. diff --git a/action-services.yml b/action-services.yml new file mode 100644 index 0000000..9db03e3 --- /dev/null +++ b/action-services.yml @@ -0,0 +1,10 @@ +version: "2" + +services: + test: + build: . + command: ["/run-tests.sh"] + volumes: + - ./ecs-deploy:/ecs-deploy + - ./run-tests.sh:/run-tests.sh + - ./test.bats:/test.bats diff --git a/codeship-services.yml b/codeship-services.yml deleted file mode 100644 index ebe2c33..0000000 --- a/codeship-services.yml +++ /dev/null @@ -1,6 +0,0 @@ -ecsdeploy: - build: - image: silintl/ecs-deploy - dockerfile_path: ./Dockerfile - entrypoint: bash - command: /run-tests.sh diff --git a/codeship-steps.yml b/codeship-steps.yml deleted file mode 100644 index f3ff14f..0000000 --- a/codeship-steps.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: test - service: ecsdeploy - command: /run-tests.sh - -- name: push_branch_tag - service: ecsdeploy - type: push - image_name: silintl/ecs-deploy - image_tag: "{{.Branch}}" - exclude: master - registry: https://index.docker.io/v1/ - encrypted_dockercfg_path: dockercfg.encrypted - -- name: push_latest_tag - service: ecsdeploy - type: push - image_name: silintl/ecs-deploy - image_tag: "latest" - tag: master - registry: https://index.docker.io/v1/ - encrypted_dockercfg_path: dockercfg.encrypted diff --git a/dockercfg.encrypted b/dockercfg.encrypted deleted file mode 100644 index 9b7a03f..0000000 --- a/dockercfg.encrypted +++ /dev/null @@ -1,2 +0,0 @@ -cloudbees:v1 -zDdKfbfu3yVguuUU1hjCG4LSaACQUEDI8BUCwWzqIKnAA+XS3GqqIZMlTPP0BphleYDj9QKaVJOmJvyUi9hxhVZQ1LtHMDE0t3+Ab6d13tAVVOnKyTYOnSid4Joh4Thq24xWbwew4qCrJL6kn+5OtXKg0b5CTXFwlP5nKPq6KuAVY/nxRmRlXlj6rIbB2zO4mnUC/48kgow8TZ634kitNjTp0s0G1/ywjD1OtUr9CD9Xf8DDFwxOfXNQqQM3BEjkcJe8N9u0JtI4aqAcL+TychvJEFwCiQwiO9a7Y85Fd/IxIoseLTObCTTv2O8H \ No newline at end of file From ea5a2c8f39c5f3572cc6e9086b1353e19d028726 Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Sat, 16 Mar 2024 14:43:34 -0400 Subject: [PATCH 2/5] use entrypoint instead of command --- action-services.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/action-services.yml b/action-services.yml index 9db03e3..4e58821 100644 --- a/action-services.yml +++ b/action-services.yml @@ -1,10 +1,6 @@ -version: "2" +version: "3" services: test: build: . - command: ["/run-tests.sh"] - volumes: - - ./ecs-deploy:/ecs-deploy - - ./run-tests.sh:/run-tests.sh - - ./test.bats:/test.bats + entrypoint: ["/run-tests.sh"] From 214ea6bfb5f256d5f11afc33f376127d6c4ea64c Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Mon, 18 Mar 2024 10:58:58 -0400 Subject: [PATCH 3/5] update environment variable section --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 26bab16..b8de3a0 100644 --- a/README.md +++ b/README.md @@ -172,19 +172,16 @@ this script. Use Environment Variable for tag name value ------------------------------------------- In some cases you may want to use an environment variable for the tag name of your image. -For instance, we use Codeship for continuous integration and deployment. In their Docker -environment they can build images and tag them with different variables, such as -the current unix timestamp. We want to use these unique and changing values for image tags -so that each task definition refers to a unique docker image/tag. This gives us the -ability to revert/rollback changes by just selecting a previous task definition and -updating the service. We plan to add a revert command/option to ecs-deploy to simplify this further. +For example, we want to use a unique docker image/tag for each task definition. This +gives us the ability to revert/rollback changes by just selecting a previous task +definition and updating the service. -Using the ```-e``` argument you can provide the name of an environment variable that -holds the value you wish to use for the tag. On Codeship they set an env var named CI_TIMESTAMP. +Using the `-e` argument you can provide the name of an environment variable that +holds the value you wish to use for the tag. -So we use ```ecs-deploy``` like this: +For example: - ecs-deploy -c production1 -n doorman-api -i my.private.repo/doorman-api -e CI_TIMESTAMP + ecs-deploy -c CLUSTERNAME -n SERVICENAME -i my.private.repo.com/frontend_container:latest -e CI_TIMESTAMP AWS IAM Policy Configuration ------------------------------------------- From 2be8a27b6f5759acd79938ec054a481100fdedd2 Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Mon, 18 Mar 2024 11:04:22 -0400 Subject: [PATCH 4/5] update name of workflow --- .github/workflows/{build-and-publish.yml => ci.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-and-publish.yml => ci.yml} (97%) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/ci.yml similarity index 97% rename from .github/workflows/build-and-publish.yml rename to .github/workflows/ci.yml index 02fe580..629a6b0 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build and Publish +name: Continuous Integration on: push: From ced6378c0a7ce0682c887c306e08f128249ad91b Mon Sep 17 00:00:00 2001 From: Jason Jackson Date: Mon, 18 Mar 2024 11:34:40 -0400 Subject: [PATCH 5/5] remove tag from -e example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8de3a0..4f9ff1b 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ holds the value you wish to use for the tag. For example: - ecs-deploy -c CLUSTERNAME -n SERVICENAME -i my.private.repo.com/frontend_container:latest -e CI_TIMESTAMP + ecs-deploy -c CLUSTERNAME -n SERVICENAME -i my.private.repo.com/frontend_container -e CI_TIMESTAMP AWS IAM Policy Configuration -------------------------------------------