Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Support for Windows Based Docker Images #134

Merged
merged 16 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/new-windows-base-image-requested.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: New Windows Base Version ⛭

on:
repository_dispatch:
types: [new_windows_base_image_requested]

# Further reading:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
# https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-repository-dispatch-event
# https://developer.github.com/webhooks/event-payloads/#repository_dispatch

jobs:
build:
name: "🛠 Build unityci/base"
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2

#################
# Variables #
#################
- name: Show hook input
run: |
echo "Event ${{ github.event.event_type }}"
echo "jobId: ${{ github.event.client_payload.jobId }}"
echo "repoVersion (full): ${{ github.event.client_payload.repoVersionFull }}"
echo "repoVersion (only minor and major): ${{ github.event.client_payload.repoVersionMinor }}"
echo "repoVersion (only major): ${{ github.event.client_payload.repoVersionMajor }}"

- name: Report new build
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: started
# Build info
imageType: base
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}

#############
# Setup #
#############
- name: Login to DockerHub
env:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
run: docker login --username $Env:username --password $Env:password

- name: Check if image not already exists
run: |
# Source: https://stackoverflow.com/a/39731444/3593896
function Docker-Tag-Exists {
[CmdletBinding()]
param(
[string] $Repository,
[string] $Tag
)
$Image = $Repository+":"+$Tag
docker manifest inspect $Image | Out-Null
return $?
}

if( (Docker-Tag-Exists -Repository unityci/base -Tag windows-${{ github.event.client_payload.repoVersionFull }}) ) {
echo "Image already exists. Exiting."
exit 1
}

# TODO: Cache layers, currently not supported on windows

##################
# Base image #
##################
- name: Build and Publish Windows Base Image
id: build_windows_base_image
run: |
docker build ./images/windows/base/ `
--tag unityci/base:windows-${{ github.event.client_payload.repoVersionFull }} `
--tag unityci/base:windows-${{ github.event.client_payload.repoVersionMinor }} `
--tag unityci/base:windows-${{ github.event.client_payload.repoVersionMajor }} `
--tag unityci/base:windows-latest `
--push
$imageDetails = docker buildx imagetools inspect unityci/base:windows-${{ github.event.client_payload.repoVersionFull }} | ConvertFrom-Json
echo '::set-output digest=$imageDetails.config.digest'

- name: Inspect
run: |
docker buildx imagetools inspect unityci/base:windows-${{ github.event.client_payload.repoVersionFull }}

- name: Image digest
run: echo ${{ steps.build_windows_base_image.outputs.digest }}

#################
# reporting #
#################
- name: Report publication
if: ${{ success() }}
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: published
# Build info
imageType: base
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}
# Publication info
imageRepo: unityci
imageName: base
friendlyTag: windows-${{ github.event.client_payload.repoVersionMinor }}
specificTag: windows-${{ github.event.client_payload.repoVersionFull }}
digest: ${{ steps.build_windows_base_image.outputs.digest }}

- name: Report failure
if: ${{ failure() || cancelled() }}
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: failed
# Build info
imageType: base
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}
# Failure info
reason: ${{ job.status }}
134 changes: 134 additions & 0 deletions .github/workflows/new-windows-hub-image-requested.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: New Windows Hub Version ⚙

on:
repository_dispatch:
types: [ new_windows_hub_image_requested ]

# Further reading:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch
# https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-repository-dispatch-event
# https://developer.github.com/webhooks/event-payloads/#repository_dispatch

jobs:
build:
name: "🛠 Build unityci/hub"
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2

#################
# Variables #
#################
- name: Show hook input
run: |
echo "Event ${{ github.event.event_type }}"
echo "jobId: ${{ github.event.client_payload.jobId }}"
echo "repoVersion (full): ${{ github.event.client_payload.repoVersionFull }}"
echo "repoVersion (only minor and major): ${{ github.event.client_payload.repoVersionMinor }}"
echo "repoVersion (only major): ${{ github.event.client_payload.repoVersionMajor }}"

- name: Report new build
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: started
# Build info
imageType: hub
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}

#############
# Setup #
#############
- name: Login to DockerHub
env:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
run: docker login --username $Env:username --password $Env:password

- name: Check if image not already exists
run: |
# Source: https://stackoverflow.com/a/39731444/3593896
function Docker-Tag-Exists {
[CmdletBinding()]
param(
[string] $Repository,
[string] $Tag
)
$Image = $Repository+":"+$Tag
docker manifest inspect $Image | Out-Null
return $?
}

if( (Docker-Tag-Exists -Repository unityci/base -Tag windows-${{ github.event.client_payload.repoVersionFull }}) ) {
echo "Image already exists. Exiting."
exit 1
}

# TODO: Cache layers, currently not supported on windows


############################
# Pull previous images #
############################
- name: Pull base image (must exist)
run: docker pull unityci/base:windows-${{ github.event.client_payload.repoVersionFull }}

#################
# Hub image #
#################
- name: Build and Publish Windows Hub Image
id: build_windows_hub_image
run: |
docker build ./images/windows/hub/ `
--tag unityci/hub:windows-${{ github.event.client_payload.repoVersionFull }} `
--tag unityci/hub:windows-${{ github.event.client_payload.repoVersionMinor }} `
--tag unityci/hub:windows-${{ github.event.client_payload.repoVersionMajor }} `
--tag unityci/hub:windows-latest `
--push
$imageDetails = docker buildx imagetools inspect unityci/hub:windows-${{ github.event.client_payload.repoVersionFull }} | ConvertFrom-Json
echo '::set-output digest=$imageDetails.config.digest'

- name: Inspect
run: |
docker buildx imagetools inspect unityci/hub:windows-${{ github.event.client_payload.repoVersionFull }}

- name: Image digest
run: echo ${{ steps.build_windows_hub_image.outputs.digest }}

#################
# reporting #
#################
- name: Report publication
if: ${{ success() }}
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: published
# Build info
imageType: hub
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}
# Publication info
imageRepo: unityci
imageName: hub
friendlyTag: windows-${{ github.event.client_payload.repoVersionMinor }}
specificTag: windows-${{ github.event.client_payload.repoVersionFull }}
digest: ${{ steps.build_windows_hub_image.outputs.digest }}

- name: Report failure
if: ${{ failure() || cancelled() }}
uses: ./.github/workflows/actions/report-to-backend
with:
token: ${{ secrets.VERSIONING_TOKEN }}
jobId: ${{ github.event.client_payload.jobId }}
status: failed
# Build info
imageType: hub
baseOs: windows
repoVersion: ${{ github.event.client_payload.repoVersionFull }}
# Failure info
reason: ${{ job.status }}
Loading