explicite group #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test, Dev Build & Release Publish | |
# When its time to do a release do a full cross platform build for all supported | |
# architectures and push all of them to Docker Hub & Github container registry. | |
# Only trigger on semver shaped tags. | |
on: | |
push: | |
tags: | |
- "*" | |
branches: | |
- dev | |
pull_request: | |
branches: | |
- "main" | |
- "dev" | |
paths-ignore: | |
- "**/README.md" | |
- "**/.github" | |
jobs: | |
docker-image-test-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set Docker Tags | |
id: set-docker-tags | |
run: | | |
DOCKER_TAGS="unknown" | |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/dev" ]; then | |
DOCKER_TAGS="dev" | |
else | |
DOCKER_TAGS="type=semver,pattern={{version}} type=semver,pattern={{major}}" | |
fi | |
echo "::set-output name=docker_tags::$DOCKER_TAGS" | |
shell: bash | |
- name: Set Docker Image Names | |
id: set-docker-image-names | |
run: | | |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/dev" ]; then | |
IMAGE_NAMES="hibare/moni" | |
else | |
IMAGE_NAMES="hibare/moni ghcr.io/hibare/moni" | |
fi | |
echo "::set-output name=docker_image_names::$IMAGE_NAMES" | |
shell: bash | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ steps.set-docker-image-names.outputs.docker_image_names}} | |
tags: ${{ steps.set-docker-tags.outputs.docker_tags }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |