From c953b2f9f6716ed69cc2e6f2b504a4c649937b1b Mon Sep 17 00:00:00 2001 From: Vishaal Pal Date: Mon, 21 Feb 2022 18:05:33 +1100 Subject: [PATCH 1/5] Added GitHub actions workflow and README file in my folder on the playground repo. --- .../vishaalpal-gh-actions-workflow.yaml | 19 +++++++++++++++++++ vishaalpal/README.md | 1 + 2 files changed, 20 insertions(+) create mode 100644 .github/workflows/vishaalpal-gh-actions-workflow.yaml create mode 100644 vishaalpal/README.md diff --git a/.github/workflows/vishaalpal-gh-actions-workflow.yaml b/.github/workflows/vishaalpal-gh-actions-workflow.yaml new file mode 100644 index 0000000..969bcad --- /dev/null +++ b/.github/workflows/vishaalpal-gh-actions-workflow.yaml @@ -0,0 +1,19 @@ +on: + pull_request: + paths: + - 'vishaalpal/*' + +jobs: + comment_pr: + runs-on: ubuntu-latest + name: Comment on all PRs targeting vishaalpal/* + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + + with: + message: 'Well done ${{ secrets.VISHAALPAL_NAME }} ! This is a nice PR.' + GITHUB_TOKEN: ${{ secrets.VISHAALPAL_GH_PAT }} diff --git a/vishaalpal/README.md b/vishaalpal/README.md new file mode 100644 index 0000000..7fe715d --- /dev/null +++ b/vishaalpal/README.md @@ -0,0 +1 @@ +This is a README file for exercise c05-actions01 by vishaalpal. From 39bdf3b9d3512669ce4144b53facedbd1807324d Mon Sep 17 00:00:00 2001 From: Vishaal Pal Date: Tue, 22 Feb 2022 02:16:16 +1100 Subject: [PATCH 2/5] Adding files for exercise c05-actions02 --- .../vishaalpal-c05-actions02-workflow.yaml | 34 +++++++++++++++++++ vishaalpal/c05-actions02/Dockerfile | 2 ++ vishaalpal/c05-actions02/Makefile | 20 +++++++++++ vishaalpal/c05-actions02/README.md | 1 + vishaalpal/c05-actions02/docker-compose.yaml | 5 +++ .../vishaalpal-c05-actions02-workflow.yaml | 34 +++++++++++++++++++ .../vishaalpal-gh-actions-workflow.yaml | 19 +++++++++++ 7 files changed, 115 insertions(+) create mode 100644 .github/workflows/vishaalpal-c05-actions02-workflow.yaml create mode 100644 vishaalpal/c05-actions02/Dockerfile create mode 100644 vishaalpal/c05-actions02/Makefile create mode 100644 vishaalpal/c05-actions02/README.md create mode 100644 vishaalpal/c05-actions02/docker-compose.yaml create mode 100644 vishaalpal/c05-actions02/vishaalpal-c05-actions02-workflow.yaml create mode 100644 vishaalpal/c05-actions02/vishaalpal-gh-actions-workflow.yaml diff --git a/.github/workflows/vishaalpal-c05-actions02-workflow.yaml b/.github/workflows/vishaalpal-c05-actions02-workflow.yaml new file mode 100644 index 0000000..b0c0c0a --- /dev/null +++ b/.github/workflows/vishaalpal-c05-actions02-workflow.yaml @@ -0,0 +1,34 @@ +on: + pull_request: + paths: + - 'vishaalpal/c05-actions02/*' + +jobs: + comment_pr: + runs-on: ubuntu-latest + name: 3m to build, push and comment pr + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: login docker hub + env: + VISHAALPAL_DH_TOKEN: ${{ secrets.VISHAALPAL_DH_TOKEN }} + VISHAALPAL_DH_USERNAME: ${{ secrets.VISHAALPAL_DH_USERNAME }} + working-directory: vishaalpal/c05-actions02/ + run: make login_dockerhub + + - name: build docker image + working-directory: vishaalpal/c05-actions02/ + run: make build_image + + - name: push docker image + id: push_image_id + working-directory: vishaalpal/c05-actions02/ + run: make push_image + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + with: + message: 'Image name ${{ env.FULLIMAGEID }} has been pushed to dockerhub.' + GITHUB_TOKEN: ${{ secrets.VISHAALPAL_GH_PAT }} \ No newline at end of file diff --git a/vishaalpal/c05-actions02/Dockerfile b/vishaalpal/c05-actions02/Dockerfile new file mode 100644 index 0000000..6c5b057 --- /dev/null +++ b/vishaalpal/c05-actions02/Dockerfile @@ -0,0 +1,2 @@ +FROM httpd:2.4.41 +RUN echo "This is my GH actions exercise." > /usr/local/apache2/htdocs/index.html diff --git a/vishaalpal/c05-actions02/Makefile b/vishaalpal/c05-actions02/Makefile new file mode 100644 index 0000000..f7b2a61 --- /dev/null +++ b/vishaalpal/c05-actions02/Makefile @@ -0,0 +1,20 @@ +export SC_SHA = $(shell git rev-parse --short HEAD) +export IMAGE_NAME = vishaalpal/c05-actions02 +export FULL_IMAGE_NAME = "$(IMAGE_NAME):$(SC_SHA)" +DOCKER_COMPOSE = docker-compose build +DOCKERHUB_PUSH = docker push $(IMAGE_NAME):$(SC_SHA) + +all: build_image push_image + +.PHONY: build_image +build_image: + $(DOCKER_COMPOSE) + +.PHONY: login_dockerhub +login_dockerhub: + @echo $(VISHAALPAL_DH_TOKEN) | docker login -u $(VISHAALPAL_DH_USERNAME) --password-stdin + +.PHONY: push_image +push_image: + $(DOCKERHUB_PUSH) + echo "FULLIMAGEID=$(IMAGE_NAME):$(SC_SHA)" >> $(GITHUB_ENV) \ No newline at end of file diff --git a/vishaalpal/c05-actions02/README.md b/vishaalpal/c05-actions02/README.md new file mode 100644 index 0000000..25f81c1 --- /dev/null +++ b/vishaalpal/c05-actions02/README.md @@ -0,0 +1 @@ +This is a README file for exercise c05-actions02 by vishaalpal. diff --git a/vishaalpal/c05-actions02/docker-compose.yaml b/vishaalpal/c05-actions02/docker-compose.yaml new file mode 100644 index 0000000..a14257b --- /dev/null +++ b/vishaalpal/c05-actions02/docker-compose.yaml @@ -0,0 +1,5 @@ +version: '3.8' +services: + web: + image: ${IMAGE_NAME}:${SHORT_COMMIT_SHA} + build: . diff --git a/vishaalpal/c05-actions02/vishaalpal-c05-actions02-workflow.yaml b/vishaalpal/c05-actions02/vishaalpal-c05-actions02-workflow.yaml new file mode 100644 index 0000000..b0c0c0a --- /dev/null +++ b/vishaalpal/c05-actions02/vishaalpal-c05-actions02-workflow.yaml @@ -0,0 +1,34 @@ +on: + pull_request: + paths: + - 'vishaalpal/c05-actions02/*' + +jobs: + comment_pr: + runs-on: ubuntu-latest + name: 3m to build, push and comment pr + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: login docker hub + env: + VISHAALPAL_DH_TOKEN: ${{ secrets.VISHAALPAL_DH_TOKEN }} + VISHAALPAL_DH_USERNAME: ${{ secrets.VISHAALPAL_DH_USERNAME }} + working-directory: vishaalpal/c05-actions02/ + run: make login_dockerhub + + - name: build docker image + working-directory: vishaalpal/c05-actions02/ + run: make build_image + + - name: push docker image + id: push_image_id + working-directory: vishaalpal/c05-actions02/ + run: make push_image + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + with: + message: 'Image name ${{ env.FULLIMAGEID }} has been pushed to dockerhub.' + GITHUB_TOKEN: ${{ secrets.VISHAALPAL_GH_PAT }} \ No newline at end of file diff --git a/vishaalpal/c05-actions02/vishaalpal-gh-actions-workflow.yaml b/vishaalpal/c05-actions02/vishaalpal-gh-actions-workflow.yaml new file mode 100644 index 0000000..969bcad --- /dev/null +++ b/vishaalpal/c05-actions02/vishaalpal-gh-actions-workflow.yaml @@ -0,0 +1,19 @@ +on: + pull_request: + paths: + - 'vishaalpal/*' + +jobs: + comment_pr: + runs-on: ubuntu-latest + name: Comment on all PRs targeting vishaalpal/* + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + + with: + message: 'Well done ${{ secrets.VISHAALPAL_NAME }} ! This is a nice PR.' + GITHUB_TOKEN: ${{ secrets.VISHAALPAL_GH_PAT }} From e2b444c3e70d3c620b58b361c87a85460b3a389c Mon Sep 17 00:00:00 2001 From: Vishaal Pal Date: Tue, 22 Feb 2022 02:25:54 +1100 Subject: [PATCH 3/5] Updating docker-compose.yaml --- vishaalpal/c05-actions02/docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vishaalpal/c05-actions02/docker-compose.yaml b/vishaalpal/c05-actions02/docker-compose.yaml index a14257b..c110cba 100644 --- a/vishaalpal/c05-actions02/docker-compose.yaml +++ b/vishaalpal/c05-actions02/docker-compose.yaml @@ -1,5 +1,5 @@ version: '3.8' services: web: - image: ${IMAGE_NAME}:${SHORT_COMMIT_SHA} + image: ${IMAGE_NAME}:${SC_SHA} build: . From 62162a6f1234fdc7b1b8b07e442ba05d991e75b3 Mon Sep 17 00:00:00 2001 From: Vishaal Pal Date: Tue, 22 Feb 2022 03:09:05 +1100 Subject: [PATCH 4/5] Updated makefile --- vishaalpal/c05-actions02/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vishaalpal/c05-actions02/Makefile b/vishaalpal/c05-actions02/Makefile index f7b2a61..da9020f 100644 --- a/vishaalpal/c05-actions02/Makefile +++ b/vishaalpal/c05-actions02/Makefile @@ -1,5 +1,5 @@ export SC_SHA = $(shell git rev-parse --short HEAD) -export IMAGE_NAME = vishaalpal/c05-actions02 +export IMAGE_NAME = vee94/c05-actions02 export FULL_IMAGE_NAME = "$(IMAGE_NAME):$(SC_SHA)" DOCKER_COMPOSE = docker-compose build DOCKERHUB_PUSH = docker push $(IMAGE_NAME):$(SC_SHA) @@ -12,7 +12,7 @@ build_image: .PHONY: login_dockerhub login_dockerhub: - @echo $(VISHAALPAL_DH_TOKEN) | docker login -u $(VISHAALPAL_DH_USERNAME) --password-stdin + @echo $(VISHAALPAL_DH_TOKEN) | docker login -u $(VISHAALPAL_DH_USERNAME) --password-stdin .PHONY: push_image push_image: From 16bac10d80f777a5117366956b2db421b2580fb2 Mon Sep 17 00:00:00 2001 From: Vishaal Pal Date: Tue, 22 Feb 2022 03:12:35 +1100 Subject: [PATCH 5/5] Making changes to dockerfile for next PR. --- vishaalpal/c05-actions02/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vishaalpal/c05-actions02/Dockerfile b/vishaalpal/c05-actions02/Dockerfile index 6c5b057..eafda86 100644 --- a/vishaalpal/c05-actions02/Dockerfile +++ b/vishaalpal/c05-actions02/Dockerfile @@ -1,2 +1,2 @@ FROM httpd:2.4.41 -RUN echo "This is my GH actions exercise." > /usr/local/apache2/htdocs/index.html +RUN echo "This is my GH actions exercise v2." > /usr/local/apache2/htdocs/index.html