Use gh artifacts instead of registry #34
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: 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: | |
- name: login to GitHub container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- 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: push image | |
run: | | |
echo $env:IMAGE_VERSION | |
$tag=$env:IMAGE_VERSION | |
docker image save -o installer-cache.tar ghcr.io/jsturtevant/debug-installer-cache:$tag | |
- name: Upload artifacts | |
uses: actions/upload-artifact@master | |
with: | |
name: installer-cache-image | |
path: 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: ``gh run download $env:GITHUB_RUN_ID -n installer-cache.tar``. | |
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 test image | |
uses: actions/download-artifact@master | |
with: | |
name: installer-cache-image | |
- name: import cache image | |
run: | | |
docker load -i installer-cache.tar | |
- 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=$(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 |