Skip to content
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
45 changes: 28 additions & 17 deletions .github/workflows/gpavelar-gh-actions02-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,29 @@ 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'

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
run: make docker-build
run: |
make docker-build
shell: bash

- name: Docker Push Image
env:
Expand All @@ -24,16 +36,15 @@ jobs:

- 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 }}"
message: "${{ steps.vars.outputs.image }}:${{ steps.vars.outputs.tag }}"
repo-token: ${{ secrets.GPAVELAR_PAT }}
allow-repeats: false


# 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
3 changes: 3 additions & 0 deletions gpavelar/c05-actions02/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions gpavelar/c05-actions02/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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} .
@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}
@docker login --username ${DH_USERNAME} --password ${GPAVELAR_DH_TOKEN}
.PHONY: dh-login
46 changes: 32 additions & 14 deletions gpavelar/c05-actions02/README-actions02.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```