Skip to content

Use gh artifacts instead of registry #40

Use gh artifacts instead of registry

Use gh artifacts instead of registry #40

Workflow file for this run

name: image
on:
push:
tags: ["image-v*"]
pull_request:
branches:
- main
path:
- 'images/**'
- '.github/workflows/images.yaml'
- '.github/workflows/cleanup.yaml'
permissions:
packages: write
pull-requests: write
defaults:
run:
working-directory: images
jobs:
build-installer-image:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
# set image version based on event type
- name: get version from tag
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
run: |
$imageversion=$env:GITHUB_REF_NAME -replace "image-", ""
"IMAGE_VERSION=$imageversion" >> $env:GITHUB_ENV
- name: get version for PR
if: ${{ github.event_name == 'pull_request' }}
run: |
"IMAGE_VERSION=pr-${{ github.event.number }}" >> $env:GITHUB_ENV
# build and publish image
# need to always publish this image so can use it to build the debug image for verification
- name: build image
run: |
echo $env:IMAGE_VERSION
.\build-installer-cache.ps1 -version $env:IMAGE_VERSION
- name: save image
run: |
echo $env:IMAGE_VERSION
$tag=$env:IMAGE_VERSION
docker image save -o ./installer-cache.tar ghcr.io/jsturtevant/debug-installer-cache:$tag
ls
- name: Upload artifacts
uses: actions/upload-artifact@master
with:
name: installer-cache-image
path: images/installer-cache.tar
- name: comment on PR
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$comment=@"
Thank you for the contribution :rocket:
The debug installer cache image has been published the PR's artifacts. You can download it via the instructions at https://docs.github.com/en/actions/managing-workflow-runs/downloading-workflow-artifacts
Using gh cli download it: ``gh run download $env:GITHUB_RUN_ID -n installer-cache-image``. Note it is a LARGE file.
Import it with ``docker load -i installer-cache.tar``.
"@
gh api --method POST -H "Accept: application/vnd.github+json" /repos/jsturtevant/windows-debug/issues/${{ github.event.pull_request.number }}/comments -f body="$comment"
build-debug-image:
needs: build-installer-image
runs-on: ubuntu-latest
steps:
- name: Download cache image
uses: actions/download-artifact@master
with:
name: installer-cache-image
path: images
- uses: actions/checkout@v2
- name: import cache image
run: |
ls
docker load -i installer-cache.tar
# set image version based on event type
- name: get version from tag
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
run: |
imageversion=$(echo $GITHUB_REF_NAME | sed 's/^image-//')
echo "IMAGE_VERSION=$imageversion" >> $GITHUB_ENV
- name: get version for PR
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "IMAGE_VERSION=pr-${{ github.event.number }}" >> $GITHUB_ENV
# build and publish image
- name: build image
run: |
echo $IMAGE_VERSION
sudo VERSION=$IMAGE_VERSION INSTALLER_VERSION=$IMAGE_VERSION ./build.sh
- name: push image
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
run: |
echo $IMAGE_VERSION
OUTPUT=registry VERSION=$IMAGE_VERSION INSTALLER_VERSION=$IMAGE_VERSION ./build.sh