Skip to content

Commit

Permalink
feat: 4bitcss in Docker ( Fixes #50 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Apr 20, 2024
1 parent 5330010 commit b5b717b
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/Build4bitcss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -506,5 +506,45 @@ jobs:
serial: true
- name: UseHelpOut
uses: StartAutomating/HelpOut@master
- name: GitLogger
uses: GitLogging/GitLoggerAction@main
id: GitLogger
- name: Log in to ghcr.io
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker Metadata (for branch)
if: ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract Docker Metadata (for main)
if: ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
id: metaMain
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=true
- name: Build and push Docker image (from main)
if: ${{github.ref_name == 'main' || github.ref_name == 'master' || github.ref_name == 'latest'}}
uses: docker/build-push-action@master
with:
context: .
push: true
tags: ${{ steps.metaMain.outputs.tags }}
labels: ${{ steps.metaMain.outputs.labels }}
- name: Build and push Docker image (from branch)
if: ${{github.ref_name != 'main' && github.ref_name != 'master' && github.ref_name != 'latest'}}
uses: docker/build-push-action@master
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NoCoverage: true
13 changes: 13 additions & 0 deletions Build/4bitcss.GitHubWorkflow.PSDevOps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#requires -Module PSDevOps
Push-Location ($PSScriptRoot | Split-Path)
Import-BuildStep -SourcePath (
Join-Path $PSScriptRoot 'GitHub'
) -BuildSystem GitHubWorkflow

New-GitHubWorkflow -Name "Build 4bitcss" -On Push, PullRequest, Demand -Job TestPowerShellOnLinux, TagReleaseAndPublish, Build4BitCss -Environment @{
NoCoverage = $true
REGISTRY = "ghcr.io"
IMAGE_NAME = '${{ github.repository }}'
} -OutputPath (Join-Path $pwd .github\workflows\Build4bitcss.yml)

Pop-Location
80 changes: 80 additions & 0 deletions Build/GitHub/Jobs/Build4bitcss.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@{
"runs-on" = "ubuntu-latest"
if = '${{ success() }}'
steps = @(
@{
name = 'Check out repository'
uses = 'actions/checkout@v2'
},
@{
name = 'Use PSSVG Action'
uses = 'StartAutomating/PSSVG@main'
id = 'PSSVG'
},
'RunEZOut',
@{
name = 'PipeScript'
uses = 'StartAutomating/PipeScript@main'
id = 'PipeScript'
with = @{
serial = $true
}
},
'RunHelpOut',
@{
name = 'GitLogger'
uses = 'GitLogging/GitLoggerAction@main'
id = 'GitLogger'
},
@{
'name'='Log in to ghcr.io'
'uses'='docker/login-action@master'
'with'=@{
'registry'='${{ env.REGISTRY }}'
'username'='${{ github.actor }}'
'password'='${{ secrets.GITHUB_TOKEN }}'
}
},
@{
name = 'Extract Docker Metadata (for branch)'
if = '${{github.ref_name != ''main'' && github.ref_name != ''master'' && github.ref_name != ''latest''}}'
id = 'meta'
uses = 'docker/metadata-action@master'
with = @{
'images'='${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}'
}
},
@{
name = 'Extract Docker Metadata (for main)'
if = '${{github.ref_name == ''main'' || github.ref_name == ''master'' || github.ref_name == ''latest''}}'
id = 'metaMain'
uses = 'docker/metadata-action@master'
with = @{
'images'='${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}'
'flavor'='latest=true'
}
},
@{
name = 'Build and push Docker image (from main)'
if = '${{github.ref_name == ''main'' || github.ref_name == ''master'' || github.ref_name == ''latest''}}'
uses = 'docker/build-push-action@master'
with = @{
'context'='.'
'push'='true'
'tags'='${{ steps.metaMain.outputs.tags }}'
'labels'='${{ steps.metaMain.outputs.labels }}'
}
},
@{
name = 'Build and push Docker image (from branch)'
if = '${{github.ref_name != ''main'' && github.ref_name != ''master'' && github.ref_name != ''latest''}}'
uses = 'docker/build-push-action@master'
with = @{
'context'='.'
'push'='true'
'tags'='${{ steps.meta.outputs.tags }}'
'labels'='${{ steps.meta.outputs.labels }}'
}
}
)
}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/powershell

# Set the module name to the name of the module we are building
ARG ModuleName=4bitcss
# Copy the module into the container
COPY . ./usr/local/share/powershell/Modules/$ModuleName
# Create a profile that imports the module, so it is available when the container starts.
RUN pwsh -c "New-Item -Path \$Profile -ItemType File -Force | Out-Null"
RUN pwsh -c "Add-Content -Path \$Profile -Value 'Import-Module $ModuleName' -Force"

0 comments on commit b5b717b

Please sign in to comment.