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
43 changes: 43 additions & 0 deletions .github/workflows/beardedsamwise-c05-actions02.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
pull_request:
paths:
- 'beardedsamwise/c05-actions-02/*'

jobs:
build:
runs-on: ubuntu-latest
name: Push image to Docker Hub
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 1
ref: ${{ github.event.pull_request.head.sha }}

- name: Log in to Docker Hub
working-directory: beardedsamwise/c05-actions-02/
run: make login
env:
BEARDED_DOCKER: ${{ secrets.BEARDED_DOCKER }}

- name: Build Docker image
working-directory: beardedsamwise/c05-actions-02/
run: make build

- name: Push image to Docker Hub
working-directory: beardedsamwise/c05-actions-02/
run: make push

- name: Create image ID variable
working-directory: beardedsamwise/c05-actions-02/
run: make output

- name: Comment PR with latest image ID
uses: thollander/actions-comment-pull-request@v1
with:
message: 'The latest Docker image ID is: ${{ env.FULLIMAGEID }}'
GITHUB_TOKEN: ${{ secrets.BEARDED_KEY }}




2 changes: 2 additions & 0 deletions beardedsamwise/c05-actions-02/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM httpd:2.4.41
RUN echo "This is my GH actions exercise" > /usr/local/apache2/htdocs/index.html
23 changes: 23 additions & 0 deletions beardedsamwise/c05-actions-02/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SHA = $(shell git rev-parse --short HEAD)
IMAGEID = "beardedsamwise/c05-actions02"
export BEARDED_DOCKER

.PHONY: build
build:
@echo "BUILDING DOCKER IMAGE WITH TAG $(IMAGEID):$(SHA)"
docker build -t $(IMAGEID):$(SHA) .

.PHONY: push
push:
@echo "PUSHING DOCKER IMAGE TO DOCKER HUB WITH TAG c03-make01:$(SHA)"
docker push $(IMAGEID):$(SHA)

.PHONY: login
login:
echo "LOGGING IN TO DOCKER HUB..."
@echo $(BEARDED_DOCKER) | docker login --username beardedsamwise --password-stdin

.PHONY: output
output:
echo "FULLIMAGEID=$(IMAGEID):$(SHA)" >> $(GITHUB_ENV)