Skip to content

CI: build images in PRs, don't run CI on unused files #129

CI: build images in PRs, don't run CI on unused files

CI: build images in PRs, don't run CI on unused files #129

Workflow file for this run

name: build
on:
push:
branches:
tags:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'
- '.github/dependabot.yml'
- '.github/FUNDING.yml'
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'dk.sh'
- 'Makefile'
- '.github/dependabot.yml'
- '.github/FUNDING.yml'
jobs:
build_app_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.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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/app:${ref} -t ${USERNAME}/baseimage:app-${ref} \
base.alpine -f base.alpine/Dockerfile
- 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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/app:${ref} -t ${USERNAME}/baseimage:app-${ref} \
-t ghcr.io/${USERNAME}/baseimage/app:latest -t ${USERNAME}/baseimage:app-latest \
base.alpine -f base.alpine/Dockerfile
build_go_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 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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/buildgo:${ref} -t ${USERNAME}/baseimage:buildgo-${ref} \
build.go -f build.go/Dockerfile
- name: build build.go 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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/buildgo:${ref} -t ${USERNAME}/baseimage:buildgo-${ref} \
-t ghcr.io/${USERNAME}/baseimage/buildgo:latest -t ${USERNAME}/baseimage:buildgo-latest \
build.go -f build.go/Dockerfile
build_scratch_image:
runs-on: ubuntu-latest
steps:
- 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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/scratch:${ref} -t ${USERNAME}/baseimage:scratch-${ref} \
base.scratch -f base.scratch/Dockerfile
- name: build base.scratch 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 }}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push --platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/baseimage/scratch:${ref} -t ${USERNAME}/baseimage:scratch-${ref} \
-t ghcr.io/${USERNAME}/baseimage/scratch:latest -t ${USERNAME}/baseimage:scratch-latest \
base.scratch -f base.scratch/Dockerfile