Skip to content

Fix: CI caching (#6) #20

Fix: CI caching (#6)

Fix: CI caching (#6) #20

Workflow file for this run

name: build
on:
push
env:
TEST_TAG: user/cmsjson:test
LATEST_TAG: ghcr.io/guyzsarun/xrootd-cmsjson:latest
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Unit test
run: |
docker run --rm ${{ env.TEST_TAG }} python3 -m pytest -v
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out Git repository
uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
tags: ${{ env.LATEST_TAG }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Push to registry
if: always() && github.ref == 'refs/heads/master'
run: docker push ${{ env.LATEST_TAG }}