add self hosted example and update docs #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name the Action | |
name: Automation to build a container image | |
# Define when the Action is run. This example is run when there is a push to the flask-app/ directory on the app branch. | |
on: | |
push: | |
paths: | |
- August-08-2024/** | |
branches: | |
- main | |
# Define the jobs to run. A job can have multiple steps and an Action can contain multiple jobs. | |
jobs: | |
build-image: | |
# Use the latest ubuntu image to run the jobs | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1 is to checkout the github repo used to build the Dockerfile | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
# Step 2 is to login to docker hub so the image can be pushed | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
# GitHub repository secrets are used as variables to provide login information to Docker Hub | |
# DOCKERHUB_USERNAME and DOCKERHUB_TOKEN need to be added to the Actions secrets | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# Step 3 gets the date and sends it to GITHUB_OUTPUT to apply as an image tag | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d.%H')" >> $GITHUB_OUTPUT | |
# Step 4 builds and pushes the docker image | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
# Provide the August-08-2024 directory as build context | |
context: August-08-2024/. | |
# Specify where the Containerfile is located in relation to the repo base path | |
file: August-08-2024/Containerfile | |
# Enable the push to docker hub | |
push: true | |
# Provide the tags to apply to the image, this example uses the latest image tag | |
tags: | | |
ncote/workshop-webapp:${{ steps.date.outputs.date }} |