2021-04-07 18:15:28 +00:00
|
|
|
name: Publish Docker images
|
2021-01-27 01:54:11 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
schedule:
|
|
|
|
- cron: '0 10 * * *' # everyday at 10am
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- '**'
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
docker:
|
2021-03-19 12:36:52 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-04-07 18:15:28 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-06-18 15:29:24 +00:00
|
|
|
image: ['', fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer, fpm-alpine-nginx-composer-supervisor]
|
2021-04-07 18:15:28 +00:00
|
|
|
include:
|
|
|
|
- image: ''
|
|
|
|
file: Dockerfile
|
|
|
|
- image: fpm
|
|
|
|
file: fpm.Dockerfile
|
|
|
|
- image: fpm-alpine
|
|
|
|
file: fpm-alpine.Dockerfile
|
|
|
|
- image: fpm-alpine-nginx
|
|
|
|
file: fpm-alpine-nginx.Dockerfile
|
|
|
|
- image: fpm-alpine-nginx-composer
|
|
|
|
file: fpm-alpine-nginx-composer.Dockerfile
|
2021-06-18 15:29:24 +00:00
|
|
|
- image: fpm-alpine-nginx-composer-supervisor
|
|
|
|
file: fpm-alpine-nginx-composer-supervisor.Dockerfile
|
2021-01-27 01:54:11 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2021-04-07 18:15:28 +00:00
|
|
|
- name: Define tag name
|
|
|
|
id: tag-name
|
2021-01-27 01:56:38 +00:00
|
|
|
run: |
|
2021-01-27 01:54:11 +00:00
|
|
|
if [ "${GITHUB_REF}" == "refs/heads/master" -a "${GITHUB_EVENT_NAME}" != "pull_request" ]; then
|
2021-01-27 01:56:38 +00:00
|
|
|
curl -s https://api.github.com/repos/akaunting/akaunting/releases/latest \
|
|
|
|
| jq -r .tag_name | sed \
|
2021-04-07 18:15:28 +00:00
|
|
|
-e 's/^/::set-output name=tag::/'
|
2021-01-27 01:56:38 +00:00
|
|
|
else
|
2021-04-07 18:15:28 +00:00
|
|
|
echo -n "::set-output name=tag::"
|
2021-01-27 01:56:38 +00:00
|
|
|
echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_'
|
2021-01-27 01:54:11 +00:00
|
|
|
fi
|
2021-04-07 18:15:28 +00:00
|
|
|
- name: Define images tags
|
|
|
|
id: image-tags
|
|
|
|
run: |
|
|
|
|
if [ "${GITHUB_REF}" == "refs/heads/master" -a "${GITHUB_EVENT_NAME}" != "pull_request" ]; then
|
|
|
|
if [ -z ${{ matrix.image }} ]; then
|
|
|
|
echo ${{ steps.tag-name.outputs.tag }} | sed \
|
|
|
|
-e 's/\(\(\([0-9]\+\)\.[0-9]\+\)\.[0-9]\+\)/\1,\2,\3,/' \
|
|
|
|
-e 's/\([^,]\+\),/akaunting\/akaunting:\1,/g' \
|
|
|
|
-e 's/^/::set-output name=tags::/' \
|
|
|
|
-e 's/$/akaunting\/akaunting:latest/'
|
|
|
|
else
|
|
|
|
echo ${{ steps.tag-name.outputs.tag }} | sed \
|
|
|
|
-e 's/\(\(\([0-9]\+\)\.[0-9]\+\)\.[0-9]\+\)/\1-${{ matrix.image }},\2-${{ matrix.image }},\3-${{ matrix.image }},/' \
|
|
|
|
-e 's/\([^,]\+\),/akaunting\/akaunting:\1,/g' \
|
|
|
|
-e 's/^/::set-output name=tags::/'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z ${{ matrix.image }} ]; then
|
|
|
|
echo -n "::set-output name=tags::akaunting/akaunting:"
|
|
|
|
echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_'
|
|
|
|
else
|
|
|
|
echo -n "::set-output name=tags::akaunting/akaunting:"
|
|
|
|
echo "$(echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_')-${{ matrix.image }}"
|
|
|
|
fi
|
|
|
|
fi
|
2021-04-05 13:57:37 +00:00
|
|
|
- name: Set up QEMU
|
2021-05-20 08:01:56 +00:00
|
|
|
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
|
2021-04-05 13:57:37 +00:00
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
2021-05-20 08:01:56 +00:00
|
|
|
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
|
2021-04-05 13:57:37 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2021-01-27 01:54:11 +00:00
|
|
|
- name: Login to DockerHub
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
2021-04-07 18:15:28 +00:00
|
|
|
- name: Build and push images
|
2021-05-20 08:01:56 +00:00
|
|
|
if: matrix.image == '' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx'
|
2021-01-27 01:54:11 +00:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
2021-04-07 18:15:28 +00:00
|
|
|
file: ./${{ matrix.file }}
|
2021-05-17 07:41:04 +00:00
|
|
|
platforms: linux/amd64,linux/arm/v6,linux/arm64,linux/arm/v7
|
2021-01-27 01:54:11 +00:00
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2021-05-20 08:01:56 +00:00
|
|
|
tags: ${{ steps.image-tags.outputs.tags }}
|
|
|
|
- name: Build and push images
|
2021-06-18 15:29:24 +00:00
|
|
|
if: matrix.image == 'fpm-alpine-nginx-composer' || matrix.image == 'fpm-alpine-nginx-composer-supervisor'
|
2021-05-20 08:01:56 +00:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./${{ matrix.file }}
|
|
|
|
platforms: linux/amd64
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
2021-04-07 18:15:28 +00:00
|
|
|
tags: ${{ steps.image-tags.outputs.tags }}
|