Upd: Simplify GitHub actions.

This commit is contained in:
Bojan Čekrlić 2021-05-29 20:21:48 +02:00
parent 4d0e7b9755
commit 5c9e076f0b
3 changed files with 151 additions and 26 deletions

7
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

View file

@ -8,17 +8,42 @@ jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout branch
uses: actions/checkout@v2
- name: Get release version
id: version_number
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "::set-output name=RELEASE_VERSION::${GITHUB_REF:10}"
- name: Run unit tests
run: ./unit-tests.sh
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Builder info
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Cache Docker layers
uses: actions/cache@v2
@ -29,6 +54,12 @@ jobs:
restore-keys: |
${{ runner.os }}-single-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: 'boky'
password: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
- name: Run integration tests
shell: bash
env: # Or as an environment variable
@ -49,19 +80,40 @@ jobs:
- name: Run HELM chart tests
run: ./helm/tests.sh
- name: Build Alpine master
env:
DOCKER_USERNAME: 'boky'
DOCKER_PASSWORD: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
PLATFORMS: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" # linux/s390x: "rsyslog (no such package)"
run: ./build.sh -t boky/postfix:latest --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache-new" --push
- name: Build and push unmarked release
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:latest
platforms: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" # linux/s390x: "rsyslog (no such package)"
cache-from: type=local,src=/tmp/.buildx-cache/alpine
cache-to: type=local,dest=/tmp/.buildx-cache-new/alpine
build-args: |
BASE_IMAGE=alpine:latest
- name: Build Ubuntu master
env:
DOCKER_USERNAME: 'boky'
DOCKER_PASSWORD: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x"
run: ./build.sh -t boky/postfix:ubuntu-latest --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache-new" --build-arg=BASE_IMAGE=ubuntu:focal --push
- name: Build and push Alpine
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:latest-alpine
platforms: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" # linux/s390x: "rsyslog (no such package)"
cache-from: type=local,src=/tmp/.buildx-cache-new/alpine
build-args: |
BASE_IMAGE=alpine:latest
- name: Build and push Ubuntu
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:latest-ubuntu
platforms: "linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x"
cache-from: type=local,src=/tmp/.buildx-cache/ubuntu
cache-to: type=local,dest=/tmp/.buildx-cache-new/ubuntu
build-args: |
BASE_IMAGE=ubuntu:focal
- name: Move cache
run: |

View file

@ -8,26 +8,42 @@ jobs:
buildx:
runs-on: ubuntu-latest
steps:
- name: Checkout tag
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Checkout gh-pages
uses: actions/checkout@v2
with:
ref: "gh-pages"
path: "gh-pages"
fetch-depth: 1
- name: Get the build version number
- name: Get release version
id: version_number
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
echo "::set-output name=RELEASE_VERSION::${GITHUB_REF:10}"
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
install: true
- name: Builder info
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Cache Docker layers
uses: actions/cache@v2
@ -38,19 +54,66 @@ jobs:
restore-keys: |
${{ runner.os }}-single-buildx-
- name: Build Alpine tag
env:
DOCKER_USERNAME: 'boky'
DOCKER_PASSWORD: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
PLATFORMS: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le"
run: ./build.sh -t boky/postfix:$RELEASE_VERSION --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache-new" --push
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: 'boky'
password: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
- name: Build Ubuntu tag
env:
DOCKER_USERNAME: 'boky'
DOCKER_PASSWORD: '${{ secrets.DOCKER_ACCESS_TOKEN }}'
PLATFORMS: "linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x"
run: ./build.sh -t boky/postfix:ubuntu-$RELEASE_VERSION --cache-from "type=local,src=/tmp/.buildx-cache" --cache-to "type=local,dest=/tmp/.buildx-cache-new" --build-arg=BASE_IMAGE=ubuntu:focal --push
- name: Build and push unmarked release
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:$RELEASE_VERSION
platforms: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" # linux/s390x: "rsyslog (no such package)"
cache-from: type=local,src=/tmp/.buildx-cache/alpine
cache-to: type=local,dest=/tmp/.buildx-cache-new/alpine
build-args: |
BASE_IMAGE=alpine:latest
- name: Build and push Alpine
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:$RELEASE_VERSION-alpine
platforms: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le" # linux/s390x: "rsyslog (no such package)"
cache-from: type=local,src=/tmp/.buildx-cache-new/alpine
build-args: |
BASE_IMAGE=alpine:latest
- name: Build and push Ubuntu
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: boky/postfix:$RELEASE_VERSION-ubuntu
platforms: "linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x"
cache-from: type=local,src=/tmp/.buildx-cache/ubuntu
cache-to: type=local,dest=/tmp/.buildx-cache-new/ubuntu
build-args: |
BASE_IMAGE=ubuntu:focal
- name: Move cache
run: |
@ -68,10 +131,12 @@ jobs:
REPO: ${{ github.repository }}
# TODO: Include the changelog in Chart.yml as annotations.artifacthub.io/changes
# See more here: https://artifacthub.io/docs/topics/annotations/helm/#supported-annotations
- name: Package helm chart
uses: WyriHaximus/github-action-helm3@v2
with:
exec: helm package --app-version $RELEASE_VERSION --version $RELEASE_VERSION --destination ./gh-pages helm/mail
- name: Create helm chart index
uses: WyriHaximus/github-action-helm3@v2
with:
@ -82,6 +147,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./gh-pages
tag_name: gh-pages-${{ steps.version_number.outputs.RELEASE_VERSION }}
- name: Create Release
id: create_release
uses: actions/create-release@v1