Skip to content

Publish nightly dev Docker image #679

Publish nightly dev Docker image

Publish nightly dev Docker image #679

name: Publish nightly dev Docker image
on:
# Manual trigger
workflow_dispatch:
# At 06:00 AM, on Tuesday, Thursday, and Saturday
schedule:
- cron: "0 6 * * TUE,THU,SAT"
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
publish-nightly:
name: Build, Test, Publish and Deploy nightly Docker image
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: Build
run: dotnet build Smartstore.sln -c Release
- name: Test
run: dotnet test Smartstore.sln -c Release --no-restore --no-build
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#- name: Log in to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish and Push for Linux
if: matrix.os == 'ubuntu-latest'
run: |
dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained
docker build --provenance=false --build-arg SOURCE=./.build/release -f NoBuild.Dockerfile -t ghcr.io/smartstore/smartstore-linux:nightly .
docker push ghcr.io/smartstore/smartstore-linux:nightly
#docker build --build-arg VERSION=nightly -f NoBuild.Dockerfile -t smartstore/smartstore-linux:nightly .
#docker push smartstore/smartstore-linux:nightly
- name: Publish and Push for Windows
if: matrix.os == 'windows-latest'
run: |
dotnet publish src/Smartstore.Web/Smartstore.Web.csproj -c Release -o ./.build/release --no-restore --no-build --no-self-contained
docker build --build-arg SOURCE=./.build/release -f Nano.Dockerfile -t ghcr.io/smartstore/smartstore-windows:nightly .
docker push ghcr.io/smartstore/smartstore-windows:nightly
#docker build --build-arg VERSION=nightly -f NoBuild.Dockerfile -t smartstore/smartstore-windows:nightly .
#docker push smartstore/smartstore-windows:nightly
cleanup-old-packages:
name: Delete untagged nightly package versions
needs: publish-nightly
runs-on: ubuntu-latest
permissions:
packages: write
strategy:
matrix:
package: [smartstore-linux, smartstore-windows]
steps:
- name: Delete untagged versions of ${{ matrix.package }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }}
script: |
const versions = await github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg({
package_type: 'container',
package_name: '${{ matrix.package }}',
org: 'smartstore',
per_page: 100
});
const untagged = versions.data.filter(v => !v.metadata?.container?.tags?.length);
console.log(`Found ${untagged.length} untagged versions`);
for (const v of untagged) {
try {
await github.rest.packages.deletePackageVersionForOrg({
package_type: 'container',
package_name: '${{ matrix.package }}',
org: 'smartstore',
package_version_id: v.id
});
console.log(`Deleted: ${v.id} (${v.name})`);
} catch (err) {
console.log(`Failed to delete ${v.id}: ${err.message}`);
}
}