diff --git a/.github/workflows/gh-alanlima-pr-actions02.yml b/.github/workflows/gh-alanlima-pr-actions02.yml new file mode 100644 index 0000000..2c2874d --- /dev/null +++ b/.github/workflows/gh-alanlima-pr-actions02.yml @@ -0,0 +1,50 @@ +name: gh-alanlima-pr-actions02 + +on: + pull_request: + branches: + - master + paths: + - 'alanlima/c05-actions02/**/*' + +jobs: + push_image: + runs-on: ubuntu-20.04 + + steps: + - name: Code Checkout + uses: actions/checkout@v2 + + - name: Build and Push Image + working-directory: 'alanlima/c05-actions02' + env: + DOCKER_TOKEN: ${{ secrets.ALIMA_DOCKER_TOKEN }} + run: make all + + - name: Get DockerHub Tag Url + working-directory: 'alanlima/c05-actions02' + id: dockerhub + shell: bash + run: make ci_github_set_outputs + + - name: Add Comment + uses: jungwinter/comment@v1 + with: + type: create + issue_number: ${{ github.event.number }} + token: ${{ secrets.ALIMA_TOKEN }} + body: | + Well done **${{ secrets.ALIMA_NAME }}**, you are the best ๐ŸŽŠ๐ŸŽŠ๐ŸŽŠ + You wrote a fantastic code ๐Ÿงก๐Ÿงก๐Ÿงก๐Ÿงก + + **Here if the URL for the docker image that I kindly pushed to docker hub: ๐Ÿณ๐Ÿณ๐Ÿณ๐Ÿณ** + + **[${{ steps.dockerhub.outputs.image_name }}](${{ steps.dockerhub.outputs.url }})** + + ```bash + docker pull ${{ steps.dockerhub.outputs.image_name }} + ``` + + Looking forward to help you again ๐Ÿ˜œ + + ๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€๐Ÿš€ \ No newline at end of file diff --git a/alanlima/c05-actions02/Dockerfile b/alanlima/c05-actions02/Dockerfile new file mode 100644 index 0000000..1bb61c5 --- /dev/null +++ b/alanlima/c05-actions02/Dockerfile @@ -0,0 +1,6 @@ +FROM httpd:2.4.41 + +LABEL maintainer="Alan Lima" +LABEL version="v2" + +RUN echo "This is my GH actions exercise" > /usr/local/apache2/htdocs/index.html \ No newline at end of file diff --git a/alanlima/c05-actions02/Makefile b/alanlima/c05-actions02/Makefile new file mode 100644 index 0000000..20de944 --- /dev/null +++ b/alanlima/c05-actions02/Makefile @@ -0,0 +1,31 @@ +DOCKER_REGISTRY?=alanrlima +IMAGE_NAME?=devops-c05-actions02 +COMMIT_SHA?=$(shell git rev-parse --short HEAD) + +build: + @docker build \ + -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${COMMIT_SHA}\ + -f Dockerfile . +.PHONY:build + +push: + @docker push ${DOCKER_REGISTRY}/${IMAGE_NAME}:${COMMIT_SHA} +.PHONY:push + +login: + docker login \ + --username ${DOCKER_REGISTRY} \ + --password ${DOCKER_TOKEN} +.PHONY:login + +dockerhub_url: + @echo "https://hub.docker.com/repository/docker/${DOCKER_REGISTRY}/${IMAGE_NAME}/tags?page=1&name=${COMMIT_SHA}" +.PHONY:dockerhub_url + +ci_github_set_outputs: + @echo "::set-output name=url::$(shell make dockerhub_url)" + @echo "::set-output name=image_name::${DOCKER_REGISTRY}/${IMAGE_NAME}:${COMMIT_SHA}" +.PHONY:ci_github_set_outputs + +all: login build push +.PHONY: all \ No newline at end of file