Skip to content

Docker build image #166

Docker build image

Docker build image #166

Workflow file for this run

name: Docker build image
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- main # Trigger CI on main branch
paths:
- 'Dockerfile'
- '.github/workflows/docker build.yml'
- 'Modules/*'
pull_request:
branches:
- main # Trigger gated pipeline on PR to main
paths:
- 'Dockerfile'
- '.github/workflows/docker build.yml'
- 'Modules/*'
env:
IMAGE_NAME: fc_powershell
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Github Container registry
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20
with:
username: bmcclure89
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
tags: |
type=ref,event=pr
type=ref,event=branch
type=sha,format=long
type=raw,value=latest
images: |
ghcr.io/brandonmcclure/${{ env.IMAGE_NAME }}
bmcclure89/${{ env.IMAGE_NAME }}
- name: Build Docker image (non main branch)
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
if: github.ref != 'refs/heads/main'
with:
context: .
load: true
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image (main branch)
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
if: github.ref == 'refs/heads/main'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- id: lowercaseImageName
uses: ASzc/change-string-case-action@v6
with:
string: bmcclure89/${{ env.IMAGE_NAME }}
- name: Save Docker Image archive to local filesystem
run: "docker save --output fc_pwsh.tar ${{ steps.lowercaseImageName.outputs.lowercase }}"
- name: Upload application's Docker Image as pipeline artifact
uses: actions/upload-artifact@v4
with:
path: fc_pwsh.tar
name: fc_pwsh.tar