Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alanlima/c05-actions02 #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/gh-alanlima-pr-actions02.yml
Original file line number Diff line number Diff line change
@@ -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 😜

🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
6 changes: 6 additions & 0 deletions alanlima/c05-actions02/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions alanlima/c05-actions02/Makefile
Original file line number Diff line number Diff line change
@@ -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