workflows: Add automation for choco upgrade #1
Workflow file for this run
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
name: PR for updating winget | ||
# This action will run after a tag starting with "v" is published | ||
# REPLACE LATER WHEN FINISHED | ||
# on: | ||
# push: | ||
# tags: | ||
# - 'v*' | ||
# workflow_dispatch: | ||
on: | ||
push: | ||
branches: | ||
- automate-choco-workflow | ||
permissions: | ||
contents: read | ||
jobs: | ||
winget-update: | ||
permissions: | ||
contents: write # for Git to git push | ||
pull-requests: write # for creating PRs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Headlamp | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
with: | ||
token: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
# we need the full history for the git tag command, so fetch all the branches | ||
fetch-depth: 0 | ||
- name: Configure Git | ||
run: | | ||
user=${{github.actor}} | ||
if [ -z $user ]; then | ||
user=vyncent-t | ||
fi | ||
git config --global user.name "$user" | ||
git config --global user.email "[email protected]" | ||
# Set up Node.js environment, pay attention to the version | ||
# Some features might not be available in older versions | ||
- name: Create node.js environment | ||
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | ||
with: | ||
node-version: '21' | ||
# Install the app dependencies for the choco script | ||
- name: Install app dependencies | ||
run: | | ||
cd $GITHUB_WORKSPACE/app | ||
npm ci | ||
# MAYBE WE CAN USE THE SAME VERSION HERE? | ||
We set the latest tag as an environment variable before we use it in the next steps | ||
note that we have to echo the variable to the environment file to make it available in the next steps | ||
- name: Set latest tag | ||
run: | | ||
echo "Setting latest tag" | ||
latestTag=$(git tag --list --sort=version:refname 'v*' | tail -1) | ||
# Remove the 'v' from the tag | ||
latestTag=${latestTag#v} | ||
echo "LATEST_HEADLAMP_TAG=$latestTag" >> $GITHUB_ENV | ||
echo $latestTag | ||
# MAY NEED TO CHANGE THIS TO BE SENT TO A NUGET REPO LIKE FOR WINGET LATER | ||
# # checkout the winget-pkgs repository | ||
# - name: Checkout winget-pkgs | ||
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
# with: | ||
# repository: headlamp-k8s/winget-pkgs | ||
# path: winget-pkgs | ||
# token: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
# # we need the full history for the git tag command, so fetch all the branches | ||
# fetch-depth: 0 | ||
# Run the winget script | ||
- name: Create nuget package | ||
run: | | ||
echo "Running choco script" | ||
echo "Repository: ${{ github.repository }}" | ||
echo "Workspace: ${GITHUB_WORKSPACE}" | ||
echo $GITHUB_WORKSPACE | ||
pwd | ||
echo "creating nuget pkgs" | ||
cd $GITHUB_WORKSPACE/app/windows/chocolatey | ||
echo "NOTE: NEED TO FIND THE DYNAMIC PATH, MAYBE IN THIS GITHUB WORKSPACE, THAT HAS THE HEADLAMP.EXE, AND PASS IT TO THE SCRIPT" | ||
echo "NOTE: LIKELY NODE WILL NOT RUN THE ./ SHELL SCRIPT, SO WE MAY NEED TO CONVERT IT TO A NODE SCRIPT THAT MAYBE GRABS THE PATH TO THE HEADLAMP.EXE IF NOT MADE FROM APP BUILD CMD" | ||
node ./choco-bump.sh $GITHUB_WORKSPACE/app/build/dist/Headlamp-$LATEST_HEADLAMP_TAG-x64/Headlamp.exe $LATEST_HEADLAMP_TAG | ||
echo "Script finished" | ||
## REFACTOR FOR CUSTOM NUGET REPO LATER IF NEEDED | ||
# - name: Create PR branch | ||
# run: | | ||
# user=${{github.actor}} | ||
# if [ -z $user ]; then | ||
# user=vyncent-t | ||
# fi | ||
# echo "Creating PR branch" | ||
# echo "Repository: ${{ github.repository }}" | ||
# echo "Workspace: ${GITHUB_WORKSPACE}" | ||
# pwd | ||
# echo "moving to winget-pkgs directory" | ||
# cd $GITHUB_WORKSPACE/winget-pkgs | ||
# pwd | ||
# ls | ||
# echo "moving to Headlamp directory" | ||
# cd $GITHUB_WORKSPACE/winget-pkgs/manifests/h/Headlamp/Headlamp | ||
# pwd | ||
# ls | ||
# git checkout -b "winget-update-$LATEST_HEADLAMP_TAG" | ||
# git add . | ||
# git commit -s -m "Update winget package $LATEST_HEADLAMP_TAG" | ||
# git push origin "winget-update-$LATEST_HEADLAMP_TAG" | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.KINVOLK_REPOS_TOKEN }} | ||
## REFACTOR FOR CUSTOM NUGET REPO LATER IF NEEDED | ||
# - name: Create Pull Request | ||
# run: | | ||
# echo "Create pull request" | ||
# echo "continue with the following link" | ||
# echo "https://github.com/headlamp-k8s/winget-pkgs/pull/new/winget-update-$LATEST_HEADLAMP_TAG" |