Skip to content

CI/CD Pipeline

CI/CD Pipeline #39

Workflow file for this run

name: CI
on:
push:
branches:
- main
paths-ignore:
- README.md
pull_request:
branches:
- main
paths-ignore:
- README.md
schedule:
- cron: "0 0 * * 0" # Every Sunday at midnight
# Allow manual triggering of the workflow
workflow_dispatch:
inputs:
force:
description: "Force run the workflow"
required: false
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up environment variables
id: get-net-pwsh-versions
run: |
# Generate /tmp/env_vars by running the script directly
chmod +x ./scripts/get-net-pwsh-versions.sh
./scripts/get-net-pwsh-versions.sh
# Set BUILD_ARGS as a multiline env var directly from /tmp/env_vars
echo "BUILD_ARGS<<EOF" >> $GITHUB_ENV
cat /tmp/env_vars >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Debug output to verify
echo "Build args prepared:"
cat /tmp/env_vars
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository }}
tags: |
type=raw,value=latest
labels: |
org.opencontainers.image.created=$GITHUB_RUN_DATE
org.opencontainers.image.authors=${{ env.AUTHOR }}
org.opencontainers.image.url=https://hub.docker.com/r/${{ github.repository }}
org.opencontainers.image.source=$GITHUB_SERVER_URL/${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
sbom: true
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
build-args: ${{ env.BUILD_ARGS }}
- name: Update README with versions
run: |
# Extract versions from environment variables
NET_RUNTIME_LTS_VERSION=$(grep 'NET_RUNTIME_LTS_VERSION' /tmp/env_vars | cut -d '=' -f 2)
PWSH_LTS_VERSION=$(grep 'PWSH_LTS_VERSION' /tmp/env_vars | cut -d '=' -f 2)
# Set as environment variables for later steps
echo "NET_RUNTIME_LTS_VERSION=$NET_RUNTIME_LTS_VERSION" >> $GITHUB_ENV
echo "PWSH_LTS_VERSION=$PWSH_LTS_VERSION" >> $GITHUB_ENV
# Debug: Show current versions and what we're updating to
echo "Current .NET Core Runtime version in README:"
grep "| .NET Core Runtime |" README.md || echo "Pattern not found"
echo "Current PowerShell Core version in README:"
grep "| PowerShell Core" README.md || echo "Pattern not found"
echo "New .NET Core Runtime version: $NET_RUNTIME_LTS_VERSION"
echo "New PowerShell Core version: $PWSH_LTS_VERSION"
# Update README.md with the extracted versions (fixed spacing)
sed -i "s/| .NET Core Runtime | .*/| .NET Core Runtime | $NET_RUNTIME_LTS_VERSION |/" README.md
sed -i "s/| PowerShell Core | .*/| PowerShell Core | $PWSH_LTS_VERSION |/" README.md
# Verify the changes were made
echo "Updated README versions:"
grep -A 2 "| Component" README.md
- name: Check for changes
id: verify-changed-files
run: |
if git diff --quiet README.md; then
echo "No changes to README.md"
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in README.md"
echo "changed=true" >> $GITHUB_OUTPUT
git diff README.md
fi
- name: Commit and push changes
if: steps.verify-changed-files.outputs.changed == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update README.md with latest .NET Core Runtime and PowerShell Core versions"
branch: main
file_pattern: README.md
- name: Update README on Docker
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ github.repository }}