Skip to content

Commit 4edff8b

Browse files
authored
Automatic nightly build
Review published versions
2 parents 680072f + 3f5f3f4 commit 4edff8b

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
schedule:
9+
- cron: '23 0 * * 2,4'
810
workflow_dispatch:
911

1012
permissions:
11-
contents: read
12-
packages: write
13-
id-token: write
13+
contents: read
14+
packages: write
15+
id-token: write
1416

1517
env:
1618
REGISTRY: ghcr.io
@@ -19,11 +21,10 @@ env:
1921
jobs:
2022

2123
build:
22-
2324
runs-on: windows-latest
2425

2526
steps:
26-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2728

2829
- name: Log into registry ${{ env.REGISTRY }}
2930
if: github.event_name != 'pull_request'
@@ -35,15 +36,31 @@ jobs:
3536

3637
# BuildX is not supported and should not be installed or configured
3738
# Features such as multistage builds and cache support are not available
38-
- name: Docker Build
39+
- name: Get Versions
40+
id: versions
41+
env:
42+
AUTH: Bearer ${{ github.token }}
3943
run: |
44+
$publishedVersions = $vers=((Invoke-WebRequest -Headers @{ "Authorization"=$env:AUTH } -Uri https://api.github.com/users/kenmuse/packages/container/arc-windows-runner/versions).Content | ConvertFrom-Json) | %{ [PSCustomObject]@{ Id=$_.id; Url=$_.url;Tags=$_.metadata.container.tags } } | %{ $_.tags }
4045
$version = ((Invoke-WebRequest -Uri https://api.github.com/repos/actions/runner/releases/latest).Content | ConvertFrom-Json).tag_name -replace 'v',''
41-
echo "Building with runner version v${version}" >> ${env:GITHUB_STEP_SUMMARY}
4246
$hooks_version = ((Invoke-WebRequest -Uri https://api.github.com/repos/actions/runner-container-hooks/releases/latest).Content | ConvertFrom-Json).tag_name -replace 'v',''
43-
echo "Building with runner hooks version v${hooks_version}" >> ${env:GITHUB_STEP_SUMMARY}
47+
echo "PUBLISHED=$($publishedVersions -Contains "v${version}")" >> ${env:GITHUB_OUTPUT}
48+
echo "RUNNER_VERSION=${version}" >> ${env:GITHUB_OUTPUT}
49+
echo "RUNNER_HOOKS_VERSION=${hooks_version}" >> ${env:GITHUB_OUTPUT}
50+
echo "**Runner version:** v${version}" >> ${env:GITHUB_STEP_SUMMARY}
51+
echo "**Runner hooks version:** v${hooks_version}" >> ${env:GITHUB_STEP_SUMMARY}
52+
echo "**Published:** $($publishedVersions -Contains "v${version}")" >> ${env:GITHUB_STEP_SUMMARY}
53+
- name: Docker Build
54+
if: ${{ steps.versions.outputs.PUBLISHED != 'True' }}
55+
env:
56+
RUNNER_VERSION: ${{ steps.versions.outputs.RUNNER_VERSION }}
57+
RUNNER_HOOKS_VERSION: ${{ steps.versions.outputs.RUNNER_HOOKS_VERSION }}
58+
run: |
59+
$version = $env:RUNNER_VERSION
60+
$hooks_version = $env:RUNNER_HOOKS_VERSION
4461
docker build --build-arg RUNNER_CONTAINER_HOOKS_VERSION=$hooks_version --build-arg RUNNER_VERSION=$version -f Dockerfile -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:"v${version}" .
4562
- name: Docker Push
46-
if: github.event_name != 'pull_request'
63+
if: ${{ github.event_name != 'pull_request' && steps.versions.outputs.PUBLISHED != 'True' }}
4764
run: |
4865
docker push -a ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4966

0 commit comments

Comments
 (0)