fix: cache 3 #43
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: Release | |
on: | |
push: | |
branches: | |
- semrel | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Define environment variables | |
run: echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/buildx-cache | |
key: esi-opticks-${{ github.sha }} | |
- run: mkdir /tmp/buildx-cache | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build container | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.test | |
tags: ${{ env.IMAGE_SHA }} | |
#push: true | |
#load: true | |
#cache-from: type=registry,ref=user/app:latest | |
#cache-from: type=local,src=/tmp/buildx-cache | |
#cache-to: type=inline | |
#cache-to: type=local,dest=/tmp/buildx-cache-new,mode=max | |
#cache-to: type=local,dest=/tmp/buildx-cache,mode=max | |
outputs: type=docker,dest=/tmp/buildx-cache/esi-opticks-${{ github.sha }}.tar | |
#- name: Upload image for next jobs | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: esi-opticks-${{ github.sha }} | |
# path: /tmp/esi-opticks-${{ github.sha }}.tar | |
# | |
- run: ls -la /tmp/buildx-cache/ | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Define environment variables | |
run: echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/buildx-cache | |
key: esi-opticks-${{ github.sha }} | |
- run: ls -la /tmp/buildx-cache/ | |
#- name: Checkout Code | |
# uses: actions/checkout@v4 | |
##- run: .github/workflows/set_github_env.sh | |
#- name: Download image | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: esi-opticks-${{ github.sha }} | |
# path: /tmp | |
#- name: Set up Docker buildx | |
# uses: docker/setup-buildx-action@v3 | |
#- name: Login to GitHub container registry | |
# uses: docker/login-action@v3 | |
# with: | |
# registry: ghcr.io | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
#- name: Build container | |
# uses: docker/build-push-action@v5 | |
# with: | |
# file: Dockerfile.test | |
# tags: ${{ env.IMAGE_SHA }} | |
# pull: true | |
# load: true | |
# cache-from: type=registry,ref=${{ env.IMAGE_SHA }} | |
- name: Run tests | |
run: | | |
#cd /tmp/buildx-cache && tar -cv * | docker load | |
docker load --input /tmp/buildx-cache/esi-opticks-${{ github.sha }}.tar | |
docker run ${{ env.IMAGE_SHA }} curl --version | |
release: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Define environment variables | |
run: | | |
echo IMAGE_SHA=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]'):${{ github.sha }} >> $GITHUB_ENV | |
echo IMAGE_REG=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Important for Semantic Release to analyze all commits | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v4 | |
id: semantic | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
#- name: Release image | |
# run: | | |
# docker load --input /tmp/esi-opticks-${{ github.sha }}.tar | |
# docker tag ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }} ghcr.io/${{ github.repository_owner }}/esi-opticks:latest | |
# docker tag ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }} ghcr.io/${{ github.repository_owner }}/esi-opticks:latest | |
# ${{ steps.semantic.outputs.new_release_version }} | |
# docker push ghcr.io/${{ github.repository_owner }}/esi-opticks:${{ github.sha }} | |
- run: echo ${{ steps.semantic.outputs.new_release_git_tag }} | |
- run: echo ${{ steps.semantic.outputs.new_release_version }} | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.semantic.outputs.new_release_git_tag }} | |
#- name: Download image | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: esi-opticks-${{ github.sha }} | |
# path: /tmp | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/buildx-cache | |
key: esi-opticks-${{ github.sha }} | |
- name: Load Image | |
run: docker load --input /tmp/buildx-cache/esi-opticks-${{ github.sha }}.tar | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build container | |
uses: docker/build-push-action@v5 | |
with: | |
file: Dockerfile.test | |
tags: | | |
${{ env.IMAGE_REG }}:latest | |
${{ env.IMAGE_REG }}:${{ steps.semantic.outputs.new_release_version }} | |
push: true | |
cache-from: ${{ env.IMAGE_SHA }} | |
#cache-from: type=registry,ref=${{ env.IMAGE_SHA }} | |
#cache-to: type=inline | |
#outputs: type=docker,dest=/tmp/esi-opticks-${{ github.sha }}.tar |