diff --git a/.github/workflows/marshalldaniel-c05-actions01.yml b/.github/workflows/marshalldaniel-c05-actions01.yml new file mode 100644 index 0000000..ff9a38f --- /dev/null +++ b/.github/workflows/marshalldaniel-c05-actions01.yml @@ -0,0 +1,19 @@ +on: + pull_request: + paths: + - 'marshalldaniel/*' + +jobs: + comment_pr: + runs-on: ubuntu-latest + name: Comment on all PRs targeting marshalldaniel/* + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + + with: + message: 'Well done ${{ secrets.MARSHALLDANIEL_NAME }} ! This is a nice PR.' + GITHUB_TOKEN: ${{ secrets.MARSHALLDANIEL_GHKEY }} \ No newline at end of file diff --git a/.github/workflows/marshalldaniel-c05-actions02.yml b/.github/workflows/marshalldaniel-c05-actions02.yml new file mode 100644 index 0000000..f1c41b0 --- /dev/null +++ b/.github/workflows/marshalldaniel-c05-actions02.yml @@ -0,0 +1,34 @@ +on: + pull_request: + paths: + - 'marshalldaniel/*' + +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: + MARSHALLDANIEL_DH_TOKEN: ${{ secrets.MARSHALLDANIEL_DH_TOKEN }} + MARSHALLDANIEL_DH_NAME: ${{ secrets.MARSHALLDANIEL_DH_NAME }} + working-directory: marshalldaniel/c05-actions02/ + run: make login_dockerhub + + - name: build docker image + working-directory: marshalldaniel/c05-actions02/ + run: make build_image + + - name: push docker image + id: push_image_id + working-directory: marshalldaniel/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.MARSHALLDANIEL_GHKEY }} diff --git a/marshalldaniel/README.md b/marshalldaniel/README.md new file mode 100644 index 0000000..8f6e7ef --- /dev/null +++ b/marshalldaniel/README.md @@ -0,0 +1 @@ +Empty :) diff --git a/marshalldaniel/c05-actions02/Dockerfile b/marshalldaniel/c05-actions02/Dockerfile new file mode 100644 index 0000000..83cea13 --- /dev/null +++ b/marshalldaniel/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/marshalldaniel/c05-actions02/Dockerfile.v2 b/marshalldaniel/c05-actions02/Dockerfile.v2 new file mode 100644 index 0000000..83cea13 --- /dev/null +++ b/marshalldaniel/c05-actions02/Dockerfile.v2 @@ -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/marshalldaniel/c05-actions02/Makefile b/marshalldaniel/c05-actions02/Makefile new file mode 100644 index 0000000..2c8ae76 --- /dev/null +++ b/marshalldaniel/c05-actions02/Makefile @@ -0,0 +1,20 @@ +export SHORT_COMMIT_SHA = $(shell git rev-parse --short HEAD) +export IMAGE_NAME = marshalldaniel/c05-actions02 +export FULL_IMAGE_NAME = "$(IMAGE_NAME):$(SHORT_COMMIT_SHA)" +DOCKER_COMPOSE = docker-compose build +DOCKERHUB_PUSH = docker push $(IMAGE_NAME):$(SHORT_COMMIT_SHA) + +all: build_image push_image + +.PHONY: build_image +build_image: + $(DOCKER_COMPOSE) + +.PHONY: login_dockerhub +login_dockerhub: + @echo $(MARSHALLDANIEL_DH_TOKEN) | docker login -u $(MARSHALLDANIEL_DH_NAME) --password-stdin + +.PHONY: push_image +push_image: + $(DOCKERHUB_PUSH) + echo "FULLIMAGEID=$(IMAGE_NAME):$(SHORT_COMMIT_SHA)" >> $(GITHUB_ENV) \ No newline at end of file diff --git a/marshalldaniel/c05-actions02/docker-compose.yaml b/marshalldaniel/c05-actions02/docker-compose.yaml new file mode 100644 index 0000000..d2c8947 --- /dev/null +++ b/marshalldaniel/c05-actions02/docker-compose.yaml @@ -0,0 +1,5 @@ +version: '3.8' +services: + web: + image: ${IMAGE_NAME}:${SHORT_COMMIT_SHA} + build: . \ No newline at end of file