Skip to content

Prevent docker login failure #8

Prevent docker login failure

Prevent docker login failure #8

name: Build Docker image
on: [push, pull_request]
jobs:
main:
name: Docker
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
tag: [latest, debug, lto]
include:
- tag: latest
build-args: buildparams=CFLAGS=-O2 CXXFLAGS=-O2
- tag: debug
build-args: buildparams=DEBUG=y
- tag: lto
build-args: buildparams=LTO=y CFLAGS=-O2 CXXFLAGS=-O2
steps:
- name: Clone Tree
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build Docker image
run: |
docker build --build-arg buildparams="${{ matrix.build-args }}" -t ${{ matrix.tag }} . \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds --utc)"
- name: Test Docker image
run: |
cd samples
for dir in */
do
cd "$dir"
docker run --rm -v `pwd`:/usr/src/app -t ${{ matrix.tag }} make -j`nproc`
cd ..
done
- name: Push container if on master branch
if: ${{ github.ref == 'refs/heads/master' }}
run: |
docker login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}"
docker tag ${{ matrix.tag }} ghcr.io/${{ github.repository }}:${{ matrix.tag }}
docker push ghcr.io/${{ github.repository }}:${{ matrix.tag }}