Skip to content

Commit

Permalink
CI: build images in PRs, don't run CI on unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Dec 6, 2024
1 parent 5c3b4f7 commit fb18b5d
Showing 1 changed file with 49 additions and 17 deletions.
66 changes: 49 additions & 17 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ on:
push:
branches:
tags:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'

jobs:
build_app_image:
Expand All @@ -13,23 +24,31 @@ jobs:
uses: actions/checkout@v4

- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3

- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3

- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}

- name: build base.app image
- name: build base.app image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build -t ghcr.io/umputun/baseimage/app:latest base.alpine -f base.alpine/Dockerfile
- name: build and push base.app image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -39,14 +58,14 @@ jobs:
-t ghcr.io/${USERNAME}/baseimage/app:${ref} -t ${USERNAME}/baseimage:app-${ref} \
base.alpine -f base.alpine/Dockerfile
- name: build base.app latest image
- name: build and push base.app latest image
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -64,23 +83,31 @@ jobs:
uses: actions/checkout@v4

- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3

- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3

- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}

- name: build build.go image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build -t ghcr.io/umputun/baseimage/buildgo:latest build.go -f build.go/Dockerfile
- name: build build.go image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -96,8 +123,8 @@ jobs:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -111,27 +138,32 @@ jobs:
build_scratch_image:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: set up QEMU
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-qemu-action@v3

- name: set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
id: buildx
uses: docker/setup-buildx-action@v3

- name: available platforms
if: ${{ github.ref == 'refs/heads/master' }}
run: echo ${{ steps.buildx.outputs.platforms }}

- name: build base.scratch image (no push)
if: ${{ github.ref != 'refs/heads/master' }}
run: |
docker build -t ghcr.io/umputun/baseimage/scratch:latest base.scratch -f base.scratch/Dockerfile
- name: build base.scratch image
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand All @@ -147,8 +179,8 @@ jobs:
GITHUB_PACKAGE_TOKEN: ${{ secrets.GITHUBPKG }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
Expand Down

0 comments on commit fb18b5d

Please sign in to comment.