Improved CI. #303
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 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 = \"$(git rev-parse HEAD)\";" > sources/version.h | |
echo "constexpr auto GIT_TAG = \"$(git describe --tags)\";" >> 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=registry,ref=${{ env.IMAGE }}:latest | |
type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }} | |
- name: Build app | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
cache-from: | | |
type=registry,ref=${{ env.IMAGE }}:latest | |
type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }} | |
- 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=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }} | |
cache-to: type=inline | |
- 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=registry,ref=${{ env.IMAGE }}:latest | |
type=registry,ref=${{ env.IMAGE }}:${{ github.ref_name }} | |
cache-to: type=inline |