Skip to content

Import Intune Win32 package #44

Import Intune Win32 package

Import Intune Win32 package #44

Workflow file for this run

# Creates a Win32 package and imports into a target Intune tenant
# Uses secrets on the repo - TENANT_ID, CLIENT_ID, and CLIENT_SECRET
# to import the package into a target tenant
name: Import Intune Win32 package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
workflow_dispatch:
inputs:
package:
description: Package name
required: true
type: string
default: AdobeAcrobatReaderDCMUI
type:
description: Package type
type: choice
options:
- App
- Update
jobs:
create-package:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Test for packages
id: test-package
shell: powershell
working-directory: ${{ github.workspace }}
run: |
[System.Array] $Applications = ("${{ github.event.inputs.package }}").ToString() -split ","
foreach ($App in $Applications) {
$AppItem = $App.Trim()
if (Test-Path -Path "${{ github.workspace }}\packages\${{ github.event.inputs.type }}\$AppItem" -PathType "Container"){
continue
}
else {
throw "Cannot find: '${{ github.workspace }}\packages\${{ github.event.inputs.type }}\$AppItem'."
}
}
- name: Install and cache PowerShell modules
id: psmodulecache
uses: potatoqualitee/[email protected]
with:
modules-to-cache: "MSAL.PS::, IntuneWin32App::, Evergreen::, VcRedist::"
updatable: true
shell: powershell
# Create the app package
- name: Authn to the Graph API and create packages
id: upload-package
shell: powershell
working-directory: ${{ github.workspace }}
env:
TENANT_ID: ${{ secrets.TENANT_ID }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
run: |
Import-Module -Name "MSAL.PS", "IntuneWin32App", "Evergreen", "VcRedist" -Force
# Authenticate to the Graph API; expects secrets to be passed into environment variables
Write-Information -MessageData "Authenticate to the Graph API" -InformationAction "Continue"
$params = @{
TenantId = "$env:TENANT_ID"
ClientId = "$env:CLIENT_ID"
ClientSecret = "$env:CLIENT_SECRET"
ErrorAction = "Stop"
}
Connect-MSIntuneGraph @params
# Convert $Application into an array because we can't pass an array via inputs into the workflow
[System.Array] $Applications = ("${{ github.event.inputs.package }}").ToString() -split "," | ForEach-Object { $_.Trim() }
# Import packages into the tenant
$params = @{
Path = "${{ github.workspace }}\packages"
Application = $Applications
Type = "${{ github.event.inputs.type }}"
WorkingPath = "${{ github.workspace }}\output"
Import = $true
}
& "${{ github.workspace }}\New-Win32Package.ps1" @params