ops: Fix CICD docker usage
All checks were successful
ci / docker-build-and-test (push) Successful in 3m11s
All checks were successful
ci / docker-build-and-test (push) Successful in 3m11s
This commit is contained in:
@@ -8,65 +8,21 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '0 1 * * 0'
|
- cron: '0 1 * * 0'
|
||||||
|
|
||||||
# https://docs.docker.com/build/ci/github-actions/share-image-jobs/
|
|
||||||
# just using caches instead of artifact upload.
|
|
||||||
jobs:
|
jobs:
|
||||||
docker-build:
|
docker-build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: docker/setup-buildx-action@v2
|
- uses: docker/setup-buildx-action@v2
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.20'
|
|
||||||
-
|
|
||||||
name: Create docker cache folder
|
|
||||||
run: mkdir -p /tmp/docker
|
|
||||||
-
|
|
||||||
name: Hash dockerfile
|
|
||||||
id: dockerfile-hash
|
|
||||||
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
|
||||||
with:
|
|
||||||
patterns: builder.Dockerfile
|
|
||||||
-
|
|
||||||
name: Restore docker image
|
|
||||||
id: cache-docker
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: /tmp/docker
|
|
||||||
key: ${{ runner.os }}-docker-${{ steps.dockerfile-hash.outputs.hash }}
|
|
||||||
-
|
-
|
||||||
name: Build docker builder-image
|
name: Build docker builder-image
|
||||||
if: steps.cache-docker.outputs.cache-hit != 'true'
|
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: builder.Dockerfile
|
file: builder.Dockerfile
|
||||||
tags: cproject-builder:latest
|
tags: cproject-builder:latest
|
||||||
outputs: type=docker,dest=/tmp/docker/${{ runner.os }}-builder-image.tar
|
push: false
|
||||||
|
load: true
|
||||||
build-and-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: docker-build
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: docker/setup-buildx-action@v2
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: '1.20'
|
|
||||||
-
|
|
||||||
name: Hash dockerfile
|
|
||||||
id: dockerfile-hash
|
|
||||||
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
|
|
||||||
with:
|
|
||||||
patterns: builder.Dockerfile
|
|
||||||
-
|
|
||||||
name: Restore docker image
|
|
||||||
id: cache-docker
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: /tmp/docker
|
|
||||||
key: ${{ runner.os }}-docker-${{ steps.dockerfile-hash.outputs.hash }}
|
|
||||||
-
|
-
|
||||||
name: Build library
|
name: Build library
|
||||||
uses: https://github.com/addnab/docker-run-action@v3
|
uses: https://github.com/addnab/docker-run-action@v3
|
||||||
@@ -99,5 +55,3 @@ jobs:
|
|||||||
name: reports-${{github.run_number}}
|
name: reports-${{github.run_number}}
|
||||||
path: ${{ env.ASSET }}
|
path: ${{ env.ASSET }}
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
|
|
||||||
# TODO: delete cache on merge.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user