PSGallery Publish #496
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 workflow publishes new modules to PSGallery on pull requests that close on the master branch. | |
name: PSGallery Publish | |
# Controls when the action will run. | |
on: # Triggers the workflow on push or pull request events but only for the master branch | |
#push: | |
#branches: [ master ] | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
workflow_run: | |
workflows: ["Version Bump"] | |
types: | |
- completed | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: windows-2019 | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
#Cache Modules that are required by publishing modules | |
- name: Specify PowerShell modules to cache | |
id: psmodulecache | |
uses: potatoqualitee/[email protected] | |
with: | |
modules-to-cache: ImportExcel, Posh-SSH, PSEventViewer, PSNmap, VMware.Vim, VMware.VimAutomation.Cis.Core, VMware.VimAutomation.Common, VMware.VimAutomation.Core, VMware.VimAutomation.Sdk | |
#Run pwsh functions to publish the module | |
- name: Install Required Modules, Update Manifests, Publish updated Modules, and commit manifest changes | |
env: | |
NUGET_KEY: ${{ secrets.PS_GALLERY_KEY }} | |
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
shell: pwsh | |
run: | | |
# Attempt to resolve future nuget issues observed on 2023/03/15 | |
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile "$env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\NuGet.exe" | |
Install-module powershellget -force -Allowclobber | |
Import-Module powershellget | |
#Impoort Modules | |
Get-Module ImportExcel, Posh-SSH, PSEventViewer, PSNmap, VMware.Vim, VMware.VimAutomation.Cis.Core, VMware.VimAutomation.Common, VMware.VimAutomation.Core, VMware.VimAutomation.Sdk | Import-Module | |
#Set-PSRepository PSGallery -InstallationPolicy Trusted | |
#Install-Module PSEventViewer -Force -Allowclobber | |
#Install-Module Posh-SSH -Force -Allowclobber -AllowPrerelease | |
#Install-Module -Name VMware.VimAutomation.Core -Force | |
#Import and Run Scripts | |
$workingdirectory = (Get-Location).path | |
. "$workingdirectory\.github\workflows\scripts\New-Manifest.ps1" | |
. "$workingdirectory\.github\workflows\scripts\Invoke-PublishModules.ps1" | |
Invoke-PublishModules | |
#Publish new manifest files to the repository | |
git config --global user.email $env:GIT_EMAIL | |
git config --global user.name "TheTaylorLee" | |
git add -A | |
git commit -m "rel: Manifest Update" | |
git push -u origin main |