Fixed CI cache. #312
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
on: push | |
env: | |
IMAGE: ${{ secrets.DOCKER_HUB_USERNAME }}/sdr-scanner | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up docker cache | |
uses: actions/cache@v3 | |
with: | |
path: cache | |
key: docker | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Generate version file | |
run: | | |
echo "constexpr auto GIT_COMMIT = \"${{ github.sha }}\";" > sources/version.h | |
echo "constexpr auto GIT_TAG = \"${{ github.ref_name }}\";" >> sources/version.h | |
- name: Build test | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
target: test | |
tags: ${{ env.IMAGE }}:test | |
cache-from: type=local,src=cache | |
cache-to: type=local,dest=cache,mode=max | |
- name: Build app | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
cache-from: type=local,src=cache | |
cache-to: type=local,dest=cache,mode=max | |
- name: Run test | |
run: | | |
docker run --rm ${{ env.IMAGE }}:test | |
- name: Push development version | |
if: ${{ github.ref_type == 'branch' && github.ref_name == vars.CI_BRANCH }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 | |
tags: ${{ env.IMAGE }}:${{ github.ref_name }} | |
cache-from: type=local,src=cache | |
cache-to: type=local,dest=cache,mode=max | |
- name: Push release version | |
if: ${{ github.ref_type == 'tag' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
platforms: linux/arm/v7,linux/arm64/v8,linux/amd64 | |
tags: | | |
${{ env.IMAGE }}:latest | |
${{ env.IMAGE }}:${{ github.ref_name }} | |
cache-from: type=local,src=cache | |
cache-to: type=local,dest=cache,mode=max |