forked from rancher/os-services
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
$files = Get-ChildItem -Path ./d -Include "docker-*" -Exclude "docker-compose.yml" -Recurse | ||
$filesShorted = $files | Sort-Object -Descending | ||
$latestPublished = $filesShorted[0].Name -replace "docker-","" -replace ".yml","" | ||
|
||
[array]$dockerVersionsToSkip = Get-Content ./.github/docker-versions-to-skip | ||
|
||
Write-Host "Getting latest Docker release tag to publish" | ||
$dockerReleases = Invoke-RestMethod -UseBasicParsing https://api.github.com/repos/moby/moby/releases | ||
$nonPreviewReleases = $dockerReleases | Where-Object {$_.prerelease -eq $false} | ||
$versionsShorted = $nonPreviewReleases.name | Sort-Object -Descending | ||
$latestMajor = "" | ||
$latestToPublish = "" | ||
forEach($v in $versionsShorted) { | ||
if ($latestMajor -eq "") { | ||
$latestMajor = ($v -split "\.")[0] -replace "^v","" | ||
} | ||
if ($v -like "v$($latestMajor).*") { | ||
continue | ||
} | ||
$latestToPublish = $v -replace "^v","" | ||
break | ||
} | ||
|
||
if ($latestToPublish -eq $latestPublished) { | ||
Write-Host "Version $latestToPublish is latest and already published" | ||
echo "CREATE_PR=false" >> "$GITHUB_ENV" | ||
return | ||
} | ||
if ($latestToPublish -in $dockerVersionsToSkip) { | ||
Write-Host "Version $latestToPublish is in skip list" | ||
echo "CREATE_PR=false" >> "$GITHUB_ENV" | ||
return | ||
} | ||
Write-Host "Version $latestToPublish is latest, trying to publish" | ||
try { | ||
$tarUrl = "https://download.docker.com/linux/static/stable/x86_64/docker-" + $latestToPublish + ".tgz" | ||
Invoke-RestMethod -Uri $tarUrl -Method HEAD | ||
} catch { | ||
Write-Host "Package $tarUrl is not available" | ||
$latestToPublish | Out-File ./.github/docker-versions-to-skip -Append | ||
echo "CREATE_PR=true" >> "$GITHUB_ENV" | ||
echo "DOCKER_VERSION=$latestToPublish" >> "$GITHUB_ENV" | ||
echo "ACTION=skip" >> "$GITHUB_ENV" | ||
return | ||
} | ||
|
||
"- docker-$latestToPublish" | Out-File ./index.yml -Append | ||
|
||
$dockerYML = @' | ||
docker: | ||
image: ${REGISTRY_DOMAIN}/burmilla/os-docker: | ||
'@ | ||
|
||
$dockerYML += $latestToPublish | ||
$dockerYML += @' | ||
${SUFFIX} | ||
command: ros user-docker | ||
environment: | ||
- HTTP_PROXY | ||
- HTTPS_PROXY | ||
- NO_PROXY | ||
labels: | ||
io.rancher.os.scope: system | ||
io.rancher.os.after: console | ||
net: host | ||
pid: host | ||
ipc: host | ||
uts: host | ||
privileged: true | ||
restart: always | ||
volumes_from: | ||
- all-volumes | ||
volumes: | ||
- /sys:/host/sys | ||
- /var/lib/system-docker:/var/lib/system-docker:shared | ||
'@ | ||
$dockerYML | Out-File "./d/docker-$latestToPublish.yml" -Append | ||
ln -s docker "./images/10-docker-$latestToPublish" | ||
|
||
echo "CREATE_PR=true" >> "$GITHUB_ENV" | ||
echo "DOCKER_VERSION=$latestToPublish" >> "$GITHUB_ENV" | ||
echo "ACTION=release" >> "$GITHUB_ENV" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: build-docker | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '38 01 * * 1,3' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Publish Docker | ||
shell: pwsh | ||
run: . ./.github/publish-docker.ps1 | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters