From 2180f52ddfe225ec036bd55cfcc74b0af75ef6de Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 11:52:32 +1000 Subject: [PATCH 01/19] Update Dockerfile --- gpavelar/c05-actions02/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gpavelar/c05-actions02/Dockerfile b/gpavelar/c05-actions02/Dockerfile index 982e43a..f111eed 100644 --- a/gpavelar/c05-actions02/Dockerfile +++ b/gpavelar/c05-actions02/Dockerfile @@ -1,2 +1,5 @@ FROM httpd:2.4.41 +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y git RUN echo "This is my GH actions exercise" > /usr/local/apache2/htdocs/index.html \ No newline at end of file From 06ed15166313351c22c1a4f07ac905ce5c4a3350 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 11:55:54 +1000 Subject: [PATCH 02/19] Changing default directory --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index a2f8a8f..a76d18e 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -5,13 +5,15 @@ on: - master paths: 'gpavelar/c05-actions02/**' +defaults: + run: + working-directory: 'gpavelar/c05-actions02' + jobs: comment: name: Deploy runs-on: ubuntu-18.04 - defaults: - run: - working-directory: 'gpavelar/c05-actions02' + steps: - name: Docker build and tag From 2670e35449923bbdd4de45cc5ecbf717a441270c Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 11:58:52 +1000 Subject: [PATCH 03/19] Steps using working-directory --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index a76d18e..204c9b9 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -5,21 +5,18 @@ on: - master paths: 'gpavelar/c05-actions02/**' -defaults: - run: - working-directory: 'gpavelar/c05-actions02' - jobs: comment: name: Deploy runs-on: ubuntu-18.04 - steps: - name: Docker build and tag + working-directory: 'gpavelar/c05-actions02' run: make docker-build - name: Docker Push Image + working-directory: 'gpavelar/c05-actions02' env: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push From 83a41f659d91e99d6043bacd7fbdadab86abfe4b Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:01:55 +1000 Subject: [PATCH 04/19] change ubuntu version and working-directory path --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 204c9b9..65435e5 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -8,15 +8,15 @@ on: jobs: comment: name: Deploy - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Docker build and tag - working-directory: 'gpavelar/c05-actions02' + working-directory: './gpavelar/c05-actions02' run: make docker-build - name: Docker Push Image - working-directory: 'gpavelar/c05-actions02' + working-directory: './gpavelar/c05-actions02' env: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push From 180f1890f8e8154278ea9a072a13318d9a188f71 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:06:17 +1000 Subject: [PATCH 05/19] Remove working directory --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 65435e5..55fca57 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -1,9 +1,9 @@ -name: GPAVELAR/C05-ACTIONS02 +name: GPAVELAR/C05-ACTIONS01 on: pull_request: branches: - master - paths: 'gpavelar/c05-actions02/**' + paths: 'gpavelar/c05-actions02/***' jobs: comment: @@ -12,11 +12,11 @@ jobs: steps: - name: Docker build and tag - working-directory: './gpavelar/c05-actions02' + # working-directory: './gpavelar/c05-actions02' run: make docker-build - name: Docker Push Image - working-directory: './gpavelar/c05-actions02' + # working-directory: './gpavelar/c05-actions02' env: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push From c2af6f60af39515259c72e7e9517f9fe0f0988ac Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:07:19 +1000 Subject: [PATCH 06/19] Change file name and paths --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 55fca57..f2966ff 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -1,9 +1,9 @@ -name: GPAVELAR/C05-ACTIONS01 +name: GPAVELAR/C05-ACTIONS02 on: pull_request: branches: - master - paths: 'gpavelar/c05-actions02/***' + paths: 'gpavelar/c05-actions02/**' jobs: comment: From e91bc9b3c2211d7d2f332dbf67439eb807b4c108 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:09:44 +1000 Subject: [PATCH 07/19] Add working-directory --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index f2966ff..8eb7f06 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -12,7 +12,7 @@ jobs: steps: - name: Docker build and tag - # working-directory: './gpavelar/c05-actions02' + working-directory: 'gpavelar/c05-actions02' run: make docker-build - name: Docker Push Image From 166e861ca1e751d910de9de21433fed82e6746b6 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:15:29 +1000 Subject: [PATCH 08/19] Change .PHONY order --- gpavelar/c05-actions02/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gpavelar/c05-actions02/Makefile b/gpavelar/c05-actions02/Makefile index dc932a0..4f54d0c 100644 --- a/gpavelar/c05-actions02/Makefile +++ b/gpavelar/c05-actions02/Makefile @@ -1,7 +1,7 @@ COMPOSE_PATH = docker-compose.yml COMPOSE_ENV = docker-compose -f ${COMPOSE_PATH} COMPOSE_RUN = ${COMPOSE_ENV} run --rm -SHORT_SHA=$(shell git rev-parse --short HEAD) +SHORT_SHA=${shell git rev-parse --short HEAD} IMAGE ?= actions02 DH_USERNAME ?= gpavelar @@ -23,24 +23,24 @@ build: ##+ Builds the compose containers. ##+ ##+ Docker build ##+ -.PHONY: docker-build docker-build: @echo "Building Docker Image ${IMAGE}:${SHORT_SHA}" @docker build -t ${IMAGE}:${SHORT_SHA} . +.PHONY: docker-build ##+ ##+ Docker push image ##+ -.PHONY: docker-push docker-push: dh-login @echo "Publishing the container as ${DH_USERNAME}/${IMAGE}:${SHORT_SHA}" @docker tag ${IMAGE}:${SHORT_SHA} ${DH_USERNAME}/${IMAGE}:${SHORT_SHA} @docker push ${DH_USERNAME}/${IMAGE}:${SHORT_SHA} +.PHONY: docker-push ##+ ##+ DockerHub login ##+ -.PHONY: dh-login dh-login: @echo "Log in to a Docker registry" - @docker login --username ${DH_USERNAME} --password ${GPAVELAR_DH_TOKEN} \ No newline at end of file + @docker login --username ${DH_USERNAME} --password ${GPAVELAR_DH_TOKEN} +.PHONY: dh-login \ No newline at end of file From bd21af8ab3dfcc2dc74548eaa3338b1b1ac91531 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 12:22:37 +1000 Subject: [PATCH 09/19] Add actions v2 --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 8eb7f06..4451ccb 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -11,9 +11,13 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker build and tag working-directory: 'gpavelar/c05-actions02' run: make docker-build + shell: bash - name: Docker Push Image # working-directory: './gpavelar/c05-actions02' From 49b0664e091d0aaa213d849f5eef1a3ec6d73b9d Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:11:39 +1000 Subject: [PATCH 10/19] general working dir --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 4451ccb..f7bb46e 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -5,6 +5,10 @@ on: - master paths: 'gpavelar/c05-actions02/**' +defaults: + run: + working-directory: 'gpavelar/c05-actions02' + jobs: comment: name: Deploy @@ -15,7 +19,7 @@ jobs: uses: actions/checkout@v2 - name: Docker build and tag - working-directory: 'gpavelar/c05-actions02' + # working-directory: 'gpavelar/c05-actions02' run: make docker-build shell: bash From c76fb17fcfd5b085b89e8a526eeaca3c9b0025e0 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:35:21 +1000 Subject: [PATCH 11/19] Testing expor SHORT_SHA and IMAGE --- .../gpavelar-gh-actions02-workflow.yaml | 18 ++++++++---------- gpavelar/c05-actions02/Makefile | 6 +++--- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index f7bb46e..5aba2b4 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -19,12 +19,10 @@ jobs: uses: actions/checkout@v2 - name: Docker build and tag - # working-directory: 'gpavelar/c05-actions02' run: make docker-build shell: bash - name: Docker Push Image - # working-directory: './gpavelar/c05-actions02' env: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push @@ -36,11 +34,11 @@ jobs: with: message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" - - # uses: mshick/add-pr-comment@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} - # with: - # message: "Well done ${{ secrets.GPAVELAR_USERNAME }} ! This is a nice PR" - # repo-token-user-login: 'github-actions[bot]' - # allow-repeats: true \ No newline at end of file + - name: Comment + uses: mshick/add-pr-comment@v1 + env: + GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} + with: + message: "Well done ${{ secrets.GPAVELAR_USERNAME }} ! This is a nice PR" + repo-token-user-login: 'github-actions[bot]' + allow-repeats: false \ No newline at end of file diff --git a/gpavelar/c05-actions02/Makefile b/gpavelar/c05-actions02/Makefile index 4f54d0c..bd4ccc3 100644 --- a/gpavelar/c05-actions02/Makefile +++ b/gpavelar/c05-actions02/Makefile @@ -1,8 +1,8 @@ COMPOSE_PATH = docker-compose.yml COMPOSE_ENV = docker-compose -f ${COMPOSE_PATH} COMPOSE_RUN = ${COMPOSE_ENV} run --rm -SHORT_SHA=${shell git rev-parse --short HEAD} -IMAGE ?= actions02 +export SHORT_SHA=$$(git rev-parse --short HEAD) +export IMAGE=actions02 DH_USERNAME ?= gpavelar ##+MAKEFILE HELPER @@ -25,7 +25,7 @@ build: ##+ Builds the compose containers. ##+ docker-build: @echo "Building Docker Image ${IMAGE}:${SHORT_SHA}" - @docker build -t ${IMAGE}:${SHORT_SHA} . + @docker build -t ${IMAGE}:$(SHORT_SHA) . .PHONY: docker-build ##+ From cdbda42f62d0ff2e4d39c94a9374bc94adb8a730 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:38:00 +1000 Subject: [PATCH 12/19] Adding allow repeat on SHORT_SHA message --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 5aba2b4..ed9ba6c 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -33,6 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} with: message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" + allow-repeats: true - name: Comment uses: mshick/add-pr-comment@v1 From 1517f279c5bc1ac02a431c8cd374ca513cc22784 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:42:31 +1000 Subject: [PATCH 13/19] add echo step --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index ed9ba6c..729f973 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -27,6 +27,11 @@ jobs: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push + - name: Show SHORT SHA + run: | + echo ${SHORT_SHA} + echo ${IMAGE} + - name: Comment Image and Short SHA uses: mshick/add-pr-comment@v1 env: From c02f9d740fd195622cba17fc4645620a6b849a32 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:51:53 +1000 Subject: [PATCH 14/19] Change repo-token --- .../gpavelar-gh-actions02-workflow.yaml | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 729f973..2cec4b2 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -19,7 +19,10 @@ jobs: uses: actions/checkout@v2 - name: Docker build and tag - run: make docker-build + run: | + make docker-build + echo ${SHORT_SHA} + echo ${IMAGE} shell: bash - name: Docker Push Image @@ -27,24 +30,17 @@ jobs: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push - - name: Show SHORT SHA - run: | - echo ${SHORT_SHA} - echo ${IMAGE} - - name: Comment Image and Short SHA uses: mshick/add-pr-comment@v1 - env: - GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} with: message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" + repo-token: ${{ secrets.GPAVELAR_PAT }} allow-repeats: true - name: Comment uses: mshick/add-pr-comment@v1 - env: - GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} with: message: "Well done ${{ secrets.GPAVELAR_USERNAME }} ! This is a nice PR" repo-token-user-login: 'github-actions[bot]' + repo-token: ${{ secrets.GPAVELAR_PAT }} allow-repeats: false \ No newline at end of file From 4d4c21a7c7fa13a6c0587044878ae7c7c1091ad4 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 13:58:04 +1000 Subject: [PATCH 15/19] Hard coded test --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 2cec4b2..ccd61b2 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -32,6 +32,9 @@ jobs: - name: Comment Image and Short SHA uses: mshick/add-pr-comment@v1 + env: + IMAGE: "action02" + SHORT_SHA: "v1" with: message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" repo-token: ${{ secrets.GPAVELAR_PAT }} From 106cbfc3323da05b08e30164e562037fa4ac626b Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 14:15:04 +1000 Subject: [PATCH 16/19] Testing set-output --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index ccd61b2..943be35 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -17,6 +17,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + - name: Set tag var + id: vars + run: | + echo ::set-output name=tag::$(echo ${GITHUB_REF} | cut -d'/' -f3)-${GITHUB_SHA} - name: Docker build and tag run: | @@ -36,7 +41,8 @@ jobs: IMAGE: "action02" SHORT_SHA: "v1" with: - message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" + message: "${{ env.IMAGE }}:${{ steps.vars.outputs.tag }}" + # message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" repo-token: ${{ secrets.GPAVELAR_PAT }} allow-repeats: true From c75afb6543b928bc9b91581fbe42a51659fcf1d7 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 14:20:33 +1000 Subject: [PATCH 17/19] fix --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 943be35..f7a277a 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -21,7 +21,8 @@ jobs: - name: Set tag var id: vars run: | - echo ::set-output name=tag::$(echo ${GITHUB_REF} | cut -d'/' -f3)-${GITHUB_SHA} + echo ::set-output name=tag::$(git rev-parse --short HEAD) + echo ::set-output name=image_tag::c05-actions02 - name: Docker build and tag run: | @@ -41,7 +42,7 @@ jobs: IMAGE: "action02" SHORT_SHA: "v1" with: - message: "${{ env.IMAGE }}:${{ steps.vars.outputs.tag }}" + message: "${{ steps.vars.outputs.image_tag }}:${{ steps.vars.outputs.tag }}" # message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" repo-token: ${{ secrets.GPAVELAR_PAT }} allow-repeats: true From 7052324bc04f3acbd90dd0da3ffe8003e78bb810 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 14:26:18 +1000 Subject: [PATCH 18/19] Remove commented lines --- .github/workflows/gpavelar-gh-actions02-workflow.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index f7a277a..7fdd424 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -22,13 +22,11 @@ jobs: id: vars run: | echo ::set-output name=tag::$(git rev-parse --short HEAD) - echo ::set-output name=image_tag::c05-actions02 + echo ::set-output name=image::actions02 - name: Docker build and tag run: | make docker-build - echo ${SHORT_SHA} - echo ${IMAGE} shell: bash - name: Docker Push Image @@ -42,8 +40,7 @@ jobs: IMAGE: "action02" SHORT_SHA: "v1" with: - message: "${{ steps.vars.outputs.image_tag }}:${{ steps.vars.outputs.tag }}" - # message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" + message: "${{ steps.vars.outputs.image }}:${{ steps.vars.outputs.tag }}" repo-token: ${{ secrets.GPAVELAR_PAT }} allow-repeats: true From 312e4b98d3be6a88728b5ab244a0cc1cbf731295 Mon Sep 17 00:00:00 2001 From: Gustavo Avelar Date: Tue, 1 Sep 2020 15:12:49 +1000 Subject: [PATCH 19/19] Refactor code --- .../gpavelar-gh-actions02-workflow.yaml | 5 +- gpavelar/c05-actions02/README-actions02.md | 46 +++++++++++++------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/workflows/gpavelar-gh-actions02-workflow.yaml b/.github/workflows/gpavelar-gh-actions02-workflow.yaml index 7fdd424..81b2107 100644 --- a/.github/workflows/gpavelar-gh-actions02-workflow.yaml +++ b/.github/workflows/gpavelar-gh-actions02-workflow.yaml @@ -36,13 +36,10 @@ jobs: - name: Comment Image and Short SHA uses: mshick/add-pr-comment@v1 - env: - IMAGE: "action02" - SHORT_SHA: "v1" with: message: "${{ steps.vars.outputs.image }}:${{ steps.vars.outputs.tag }}" repo-token: ${{ secrets.GPAVELAR_PAT }} - allow-repeats: true + allow-repeats: false - name: Comment uses: mshick/add-pr-comment@v1 diff --git a/gpavelar/c05-actions02/README-actions02.md b/gpavelar/c05-actions02/README-actions02.md index 19c21ff..9ae62e9 100644 --- a/gpavelar/c05-actions02/README-actions02.md +++ b/gpavelar/c05-actions02/README-actions02.md @@ -50,32 +50,50 @@ on: - master paths: 'gpavelar/c05-actions02/**' +defaults: + run: + working-directory: 'gpavelar/c05-actions02' + jobs: comment: name: Deploy - runs-on: ubuntu-18.04 - + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set tag var + id: vars + run: | + echo ::set-output name=tag::$(git rev-parse --short HEAD) + echo ::set-output name=image::actions02 + - name: Docker build and tag - working-directory: 'gpavelar/c05-actions02/' - run: make docker-build + run: | + make docker-build + shell: bash - name: Docker Push Image - working-directory: 'gpavelar/c05-actions02/' env: GPAVELAR_DH_TOKEN: ${{ secrets.GPAVELAR_DH_TOKEN }} run: make docker-push + - name: Comment Image and Short SHA uses: mshick/add-pr-comment@v1 + env: + IMAGE: "action02" + SHORT_SHA: "v1" with: - message: "${{ env.IMAGE }}:${{ env.SHORT_SHA }}" - + message: "${{ steps.vars.outputs.image }}:${{ steps.vars.outputs.tag }}" + repo-token: ${{ secrets.GPAVELAR_PAT }} + allow-repeats: true - # uses: mshick/add-pr-comment@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GPAVELAR_PAT }} - # with: - # message: "Well done ${{ secrets.GPAVELAR_USERNAME }} ! This is a nice PR" - # repo-token-user-login: 'github-actions[bot]' - # allow-repeats: true + - name: Comment + uses: mshick/add-pr-comment@v1 + with: + message: "Well done ${{ secrets.GPAVELAR_USERNAME }} ! This is a nice PR" + repo-token-user-login: 'github-actions[bot]' + repo-token: ${{ secrets.GPAVELAR_PAT }} + allow-repeats: false ``` \ No newline at end of file