Skip to content

Commit

Permalink
consolidate push by digest/create digest artifact steps into action
Browse files Browse the repository at this point in the history
  • Loading branch information
mwestphall committed Oct 3, 2024
1 parent ca16d5d commit 3e67ea0
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 82 deletions.
65 changes: 65 additions & 0 deletions .github/actions/push-digest-local/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Push Container by Digest Action'
description: 'Pushes an image by digest to a given registry, then outputs its digest and tags as an artifact'



runs:
using: "composite"
steps:
- uses: actions/checkout@v3

- id: slash-escape
run: |
platform=${{ inputs.platform }}
echo "platform=${platform//\//-}" >> ${GITHUB_OUTPUT}
- name: Registry login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}

- id: upload-image
uses: ./.github/actions/build-container-local
with:
registry_url: ${{ inputs.registry }}
osg_series: ${{ inputs.osg_series }}
osg_repo: ${{ inputs.repo }}
base_os: ${{ inputs.os }}
platform: ${{ inputs.platform }}
push_by_digest: true
timestamp_image: ${{ inputs.timestamp_image }}
setup: false
output_image: ${{ inputs.output_image }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.upload-image.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ inputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Export tags
run: |
mkdir -p /tmp/tags
echo ${{ steps.upload-image.outputs.image-list }} > /tmp/tags/${{ inputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
- name: Upload tags
uses: actions/upload-artifact@v4
with:
name: tags-${{ inputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/tags/*
if-no-files-found: error
retention-days: 1
173 changes: 91 additions & 82 deletions .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ jobs:
echo "${PREFIX}-${OS}-${REPO}" >> ${GITHUB_OUTPUT}
echo "base_tag=${SERIES}-${OS}-${REPO}" >> ${GITHUB_OUTPUT}
- id: slash-escape
run: |
platform=${{ matrix.platform }}
echo "platform=${platform//\//-}" >> ${GITHUB_OUTPUT}
- id: build-image
uses: ./.github/actions/build-container-local
with:
Expand All @@ -58,56 +53,70 @@ jobs:
output_image: ${{ steps.custom-image-name.outputs.output_image }}


- name: Prepare CVMFS
# if: ${{ matrix.platform == 'linux/amd64' }}
run: |
sudo ./tests/setup_cvmfs.sh
# - name: Prepare CVMFS
# if: ${{ matrix.platform == 'linux/amd64' }}
# run: |
# sudo ./tests/setup_cvmfs.sh

- name: Docker + CVMFS bindmount
# if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfs
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
run: |
sudo ./tests/test_inside_gha.sh docker \
bindmount \
"$CONTAINER_IMAGE"
# - name: Docker + CVMFS bindmount
# if: ${{ matrix.platform == 'linux/amd64' }}
# id: test-docker-cvmfs
# env:
# CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
# run: |
# sudo ./tests/test_inside_gha.sh docker \
# bindmount \
# "$CONTAINER_IMAGE"

- name: Docker + cvmfsexec
# if: ${{ matrix.platform == 'linux/amd64' }}
id: test-docker-cvmfsexec
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
run: |
sudo ./tests/test_inside_gha.sh docker \
cvmfsexec \
"$CONTAINER_IMAGE"
# - name: Docker + cvmfsexec
# if: ${{ matrix.platform == 'linux/amd64' }}
# id: test-docker-cvmfsexec
# env:
# CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
# run: |
# sudo ./tests/test_inside_gha.sh docker \
# cvmfsexec \
# "$CONTAINER_IMAGE"

- name: Singularity + CVMFS bindmount
if: ${{ matrix.platform == 'linux/amd64' }}
id: test-singularity-cvmfs
env:
CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
run: |
if [[ $CONTAINER_IMAGE == *cuda* ]]; then
echo >&2 "Skipping test: \$APPTAINER_TMPDIR (${APPTAINER_TMPDIR:-/tmp}) too small for cuda-based images"
exit 0
else
sudo ./tests/test_inside_gha.sh singularity \
bindmount \
"$CONTAINER_IMAGE"
fi
# - name: Singularity + CVMFS bindmount
# if: ${{ matrix.platform == 'linux/amd64' }}
# id: test-singularity-cvmfs
# env:
# CONTAINER_IMAGE: ${{ steps.build-image.outputs.timestamp-image }}
# run: |
# if [[ $CONTAINER_IMAGE == *cuda* ]]; then
# echo >&2 "Skipping test: \$APPTAINER_TMPDIR (${APPTAINER_TMPDIR:-/tmp}) too small for cuda-based images"
# exit 0
# else
# sudo ./tests/test_inside_gha.sh singularity \
# bindmount \
# "$CONTAINER_IMAGE"
# fi

- name: Harbor login
# if: >-
# github.ref == 'refs/heads/master' &&
# github.event_name != 'pull_request' &&
# github.repository_owner == 'opensciencegrid'
uses: docker/login-action@v2
- id: upload-by-digest
uses: ./.github/actions/push-digest-local
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
osg_series: ${{ matrix.osg_series }}
osg_repo: ${{ matrix.repo }}
base_os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
base_tag: ${{ steps.custom-image-name.outputs.base_tag }}
timestamp_image: ${{ steps.build-image.outputs.timestamp-image }}
output_image: ${{ steps.custom-image-name.outputs.output_image }}

# - name: Harbor login
# # if: >-
# # github.ref == 'refs/heads/master' &&
# # github.event_name != 'pull_request' &&
# # github.repository_owner == 'opensciencegrid'
# uses: docker/login-action@v2
# with:
# registry: hub.opensciencegrid.org
# username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
# password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}

# - name: Docker login
# if: >-
Expand All @@ -121,45 +130,45 @@ jobs:
# password: ${{ secrets.DOCKER_PASSWORD }}


- id: upload-image
uses: ./.github/actions/build-container-local
with:
registry_url: hub.opensciencegrid.org
osg_series: ${{ matrix.osg_series }}
osg_repo: ${{ matrix.repo }}
base_os: ${{ matrix.os }}
platform: ${{ matrix.platform }}
push_by_digest: true
timestamp_image: ${{ steps.build-image.outputs.timestamp-image }}
setup: false
output_image: ${{ steps.custom-image-name.outputs.output_image }}
# - id: upload-image
# uses: ./.github/actions/build-container-local
# with:
# registry_url: hub.opensciencegrid.org
# osg_series: ${{ matrix.osg_series }}
# osg_repo: ${{ matrix.repo }}
# base_os: ${{ matrix.os }}
# platform: ${{ matrix.platform }}
# push_by_digest: true
# timestamp_image: ${{ steps.build-image.outputs.timestamp-image }}
# setup: false
# output_image: ${{ steps.custom-image-name.outputs.output_image }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.upload-image.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
# - name: Export digest
# run: |
# mkdir -p /tmp/digests
# digest="${{ steps.upload-image.outputs.digest }}"
# touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# - name: Upload digest
# uses: actions/upload-artifact@v4
# with:
# name: digests-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
# path: /tmp/digests/*
# if-no-files-found: error
# retention-days: 1

- name: Export tags
run: |
mkdir -p /tmp/tags
echo ${{ steps.upload-image.outputs.image-list }} > /tmp/tags/${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
# - name: Export tags
# run: |
# mkdir -p /tmp/tags
# echo ${{ steps.upload-image.outputs.image-list }} > /tmp/tags/${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}

- name: Upload tags
uses: actions/upload-artifact@v4
with:
name: tags-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
path: /tmp/tags/*
if-no-files-found: error
retention-days: 1
# - name: Upload tags
# uses: actions/upload-artifact@v4
# with:
# name: tags-${{ steps.custom-image-name.outputs.base_tag }}-${{ steps.slash-escape.outputs.platform }}
# path: /tmp/tags/*
# if-no-files-found: error
# retention-days: 1

merge-manifests:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 3e67ea0

Please sign in to comment.