Skip to content

Cache artifact

Cache artifact #42

Workflow file for this run

name: build
on:
push
env:
TEST_TAG: user/cmsjson:test
LATEST_TAG: ghcr.io/guyzsarun/xrootd-cmsjson:latest
jobs:
build:
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
tags: ${{ env.TEST_TAG }}
outputs: type=docker,dest=/tmp/myimage.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: myimage
path: /tmp/myimage.tar
test-json:
runs-on: ubuntu-latest
needs: build
steps:
- uses: docker/setup-buildx-action@v1
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: myimage
path: /tmp
- name: Unit test
run: |
docker load --input /tmp/myimage.tar
docker run --rm ${{ env.TEST_TAG }} python3 -m pytest -v
test-rpm:
runs-on: ubuntu-latest
needs: build
steps:
- uses: docker/setup-buildx-action@v1
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: myimage
path: /tmp
- name: Unit test
run: |
docker load --input /tmp/myimage.tar
docker run --rm ${{ env.TEST_TAG }} bash -c '
mkdir -p /root/rpmbuild/SOURCES/ &&
tar -cvf /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz . &&
rpmbuild -bb spec/xrootd-cmsjson.spec
'
push-registry:
runs-on: ubuntu-latest
needs: [test-json,test-rpm]
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release'
steps:
- uses: docker/setup-buildx-action@v1
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: myimage
path: /tmp
- name: Tag image
run: |
docker load --input /tmp/myimage.tar
docker tag ${{ env.TEST_TAG }} ${{ env.LATEST_TAG }}
- name: Push to registry
run: docker push ${{ env.LATEST_TAG }}