From da0f9a8358614f8767dca53844925b55806a3578 Mon Sep 17 00:00:00 2001 From: John D <427295+boostchicken@users.noreply.github.com> Date: Tue, 25 May 2021 18:42:24 -0700 Subject: [PATCH 1/2] Create docker-publish.yml --- .github/workflows/docker-publish.yml | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..b65998b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,63 @@ +name: Docker + +on: + push: + # Publish `main` as Docker `latest` image. + branches: + - main + + # Publish `1.2.3` tags as releases. + tags: + - '*' + +env: + # TODO: Change variable to your image's name. + IMAGE_NAME: aws-ecs-eds + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + + runs-on: ubuntu-latest + + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build . --file Dockerfile --tag $IMAGE_NAME + + - name: Login to DockerHub Registry + run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin + + - name: Push image + run: | + IMAGE_ID=boostchicken/$IMAGE_NAME + + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "main" ] && VERSION=latest + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION From cb64afc3d63c4f65f85a214c4558ec65d910d558 Mon Sep 17 00:00:00 2001 From: John D <427295+boostchicken@users.noreply.github.com> Date: Tue, 25 May 2021 18:43:37 -0700 Subject: [PATCH 2/2] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index b65998b..1664ff9 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -15,19 +15,9 @@ env: IMAGE_NAME: aws-ecs-eds jobs: - # Run tests. - # See also https://docs.docker.com/docker-hub/builds/automated-testing/ - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - # Push image to GitHub Packages. # See also https://docs.docker.com/docker-hub/builds/ push: - runs-on: ubuntu-latest