Skip to content

base-image-update

base-image-update #109

name: Build docker images
on:
workflow_dispatch:
repository_dispatch:
types:
- base-image-update
push:
branches:
- main
paths:
- "version.txt"
- "dockerfile"
pull_request:
branches:
- main
env:
IMAGE_NAME: ${{ vars.DOCKER_USERNAME }}/powershell-core
jobs:
docker-buildx:
runs-on: ubuntu-latest
permissions:
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version
id: pwsh_version
run: |
echo "version=$(cat version.txt | tr -d 'v')" >> $GITHUB_OUTPUT
echo "major_version=$(cat version.txt | tr -d 'v' | cut -d '.' -f 1)" >> $GITHUB_OUTPUT
- name: Powershell version
run: echo ${{ steps.pwsh_version.outputs.version }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
file: ./dockerfile
push: ${{ github.event_name != 'pull_request' }}
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max`
platforms: |
linux/amd64
linux/arm64
build-args: |
PWSH_VERSION=${{ steps.pwsh_version.outputs.version }}
MAJOR_VERSION=${{ steps.pwsh_version.outputs.major_version}}
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.pwsh_version.outputs.version }}
- name: Generate artifact attestation
if: github.event_name != 'pull_request'
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.docker_build.outputs.digest }}
# push-to-registry: ${{ github.event_name != 'pull_request' }}
- name: Send telegram notification
if: github.ref == 'refs/heads/main'
uses: appleboy/telegram-action@v0.1.1
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
πŸ–Š ${{ github.actor }} created commit:
πŸ“© Commit message: ${{ github.event.commits[0].message }}
πŸ”§ Build status: ${{ steps.docker_build.outcome }}
πŸ“š Repository: [ ${{ github.repository }} ](https://github.com/${{ github.repository }})
πŸ“¦ Image digest: ```${{ steps.docker_build.outputs.digest }}```
🐳 See new image on [Docker hub](https://hub.docker.com/r/${{ env.IMAGE_NAME }}/tags)