From c21bb2d467155297788185719c66bf116b791f6e Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 12:57:09 +0100 Subject: [PATCH 1/9] Create Dockerfile --- action-a/Dockerfile | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 action-a/Dockerfile diff --git a/action-a/Dockerfile b/action-a/Dockerfile new file mode 100644 index 0000000..7b8e05a --- /dev/null +++ b/action-a/Dockerfile @@ -0,0 +1,87 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + +# Docker image file that describes an Alpine3.12 image with PowerShell installed from .tar.gz file(s) + +FROM alpine:3.12 AS installer-env + +# Define Args for the needed to add the package +ARG PS_VERSION=7.0.0 +ARG PS_PACKAGE=powershell-${PS_VERSION}-linux-alpine-x64.tar.gz +ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} +ARG PS_INSTALL_VERSION=7 + +# Download the Linux tar.gz and save it +ADD ${PS_PACKAGE_URL} /tmp/linux.tar.gz + +# define the folder we will be installing PowerShell to +ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION + +# Create the install folder +RUN mkdir -p ${PS_INSTALL_FOLDER} + +# Unzip the Linux tar.gz +RUN tar zxf /tmp/linux.tar.gz -C ${PS_INSTALL_FOLDER} -v + +# Start a new stage so we lose all the tar.gz layers from the final image +FROM alpine:3.12.1 + +# Copy only the files we need from the previous stage +COPY --from=installer-env ["/opt/microsoft/powershell", "/opt/microsoft/powershell"] + +# Define Args and Env needed to create links +ARG PS_INSTALL_VERSION=7 +ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/$PS_INSTALL_VERSION \ + \ + # Define ENVs for Localization/Globalization + DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \ + LC_ALL=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + # set a fixed location for the Module analysis cache + PSModuleAnalysisCachePath=/var/cache/microsoft/powershell/PSModuleAnalysisCache/ModuleAnalysisCache \ + POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-Alpine-3.12 + +# Install dotnet dependencies and ca-certificates +RUN apk add --no-cache \ + ca-certificates \ + less \ + \ + # PSReadline/console dependencies + ncurses-terminfo-base \ + \ + # .NET Core dependencies + krb5-libs \ + libgcc \ + libintl \ + libssl1.1 \ + libstdc++ \ + tzdata \ + userspace-rcu \ + zlib \ + icu-libs \ + && apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache \ + lttng-ust \ + \ + # PowerShell remoting over SSH dependencies + openssh-client \ + \ + # Create the pwsh symbolic link that points to powershell + && ln -s ${PS_INSTALL_FOLDER}/pwsh /usr/bin/pwsh \ + \ + # Give all user execute permissions and remove write permissions for others + && chmod a+x,o-w ${PS_INSTALL_FOLDER}/pwsh \ + # intialize powershell module cache + # and disable telemetry + && export POWERSHELL_TELEMETRY_OPTOUT=1 \ + && pwsh \ + -NoLogo \ + -NoProfile \ + -Command " \ + \$ErrorActionPreference = 'Stop' ; \ + \$ProgressPreference = 'SilentlyContinue' ; \ + while(!(Test-Path -Path \$env:PSModuleAnalysisCachePath)) { \ + Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ + Start-Sleep -Seconds 6 ; \ + }" + +CMD [ "pwsh" ] From 619100dc822d442cb1fcda19d6f0a28ac6ec2e75 Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:02:23 +0100 Subject: [PATCH 2/9] Create entrypoint.ps1 --- action-a/entrypoint.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 action-a/entrypoint.ps1 diff --git a/action-a/entrypoint.ps1 b/action-a/entrypoint.ps1 new file mode 100644 index 0000000..3646c63 --- /dev/null +++ b/action-a/entrypoint.ps1 @@ -0,0 +1 @@ +"Hello, World! from PowerShell {0}" -f $PSVersionTable.PSVersion From af2a5e9dec7b21d6cd839c2f143829f51d010b8a Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:05:17 +0100 Subject: [PATCH 3/9] Update Dockerfile --- action-a/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/action-a/Dockerfile b/action-a/Dockerfile index 7b8e05a..19e2bfe 100644 --- a/action-a/Dockerfile +++ b/action-a/Dockerfile @@ -85,3 +85,4 @@ RUN apk add --no-cache \ }" CMD [ "pwsh" ] +ENTRYPOINT ["/entrypoint.ps1"] From d7904ae9876f751cffc40c25eec863253be76406 Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:19:14 +0100 Subject: [PATCH 4/9] Update and rename entrypoint.ps1 to entrypoint.sh --- action-a/entrypoint.ps1 | 1 - action-a/entrypoint.sh | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 action-a/entrypoint.ps1 create mode 100644 action-a/entrypoint.sh diff --git a/action-a/entrypoint.ps1 b/action-a/entrypoint.ps1 deleted file mode 100644 index 3646c63..0000000 --- a/action-a/entrypoint.ps1 +++ /dev/null @@ -1 +0,0 @@ -"Hello, World! from PowerShell {0}" -f $PSVersionTable.PSVersion diff --git a/action-a/entrypoint.sh b/action-a/entrypoint.sh new file mode 100644 index 0000000..d91f062 --- /dev/null +++ b/action-a/entrypoint.sh @@ -0,0 +1 @@ +pwsh -c {"Hello, World! from PowerShell {0}" -f $PSVersionTable.PSVersion} From 43d2011182374bafd8f41bf807a74310f1c332e9 Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:19:58 +0100 Subject: [PATCH 5/9] Update Dockerfile --- action-a/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action-a/Dockerfile b/action-a/Dockerfile index 19e2bfe..efa136f 100644 --- a/action-a/Dockerfile +++ b/action-a/Dockerfile @@ -85,4 +85,4 @@ RUN apk add --no-cache \ }" CMD [ "pwsh" ] -ENTRYPOINT ["/entrypoint.ps1"] +ENTRYPOINT ["/entrypoint.sh"] From b611a96c19c12fe7abaa41e63138e8d364cf8516 Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:23:19 +0100 Subject: [PATCH 6/9] Update entrypoint.sh --- action-a/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action-a/entrypoint.sh b/action-a/entrypoint.sh index d91f062..6a9d8e8 100644 --- a/action-a/entrypoint.sh +++ b/action-a/entrypoint.sh @@ -1 +1 @@ -pwsh -c {"Hello, World! from PowerShell {0}" -f $PSVersionTable.PSVersion} +pwsh -f hello.ps1 From 3c821c1c2b9d301ed2bff14106e06bd94af4f96e Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:24:32 +0100 Subject: [PATCH 7/9] Create action.yml --- action-a/action.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 action-a/action.yml diff --git a/action-a/action.yml b/action-a/action.yml new file mode 100644 index 0000000..1f28e37 --- /dev/null +++ b/action-a/action.yml @@ -0,0 +1,17 @@ +name: "Hello Actions" +description: "Greet someone" +author: "octocat@github.com" + +inputs: + MY_NAME: + description: "Who to greet" + required: true + default: "Max" + +runs: + using: "docker" + image: "Dockerfile" + +branding: + icon: "mic" + color: "purple" From f121615e073d76528746385b87294db27e3b5c9c Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:24:48 +0100 Subject: [PATCH 8/9] Create hello.ps1 --- action-a/hello.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 action-a/hello.ps1 diff --git a/action-a/hello.ps1 b/action-a/hello.ps1 new file mode 100644 index 0000000..1499d50 --- /dev/null +++ b/action-a/hello.ps1 @@ -0,0 +1 @@ +{"Hello, {0}!" -f $env:MY_NAME} From 5ef80210328bd67067dd444c316ae86f3cbbb95b Mon Sep 17 00:00:00 2001 From: wplj Date: Thu, 11 Mar 2021 13:29:41 +0100 Subject: [PATCH 9/9] Create main.yml --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f2809f7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,2 @@ +name: A workflow for my Hello World file +on: push