Merge branch 'main' of https://github.com/OctopusSolutionsEngineering… #59
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: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
permissions: | |
packages: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Step 3: Log in to GitHub Container Registry | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Step 4: Get Date, Build Run Number, and Force Lowercase Repository Name | |
- name: Get Date and Build Run Number for version tag | |
id: version | |
run: | | |
echo "::set-output name=tag::$(date +'%Y.%m.%d').${{ github.run_number }}" | |
echo "::set-output name=repo_lower::$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" | |
# Step 5: Build the Docker image using the lowercase repository name | |
- name: Build the Docker image | |
run: | | |
docker build -t ghcr.io/${{ steps.version.outputs.repo_lower }}/demo-frontend:${{ steps.version.outputs.tag }} -f demo-frontend/Dockerfile . | |
# Step 6: Push the Docker image to GitHub Container Registry | |
- name: Push the Docker image | |
run: | | |
docker push ghcr.io/${{ steps.version.outputs.repo_lower }}/demo-frontend:${{ steps.version.outputs.tag }} |