Skip to content

publish-docker-image #19

publish-docker-image

publish-docker-image #19

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish Docker image
on:
push:
branches: [main]
repository_dispatch:
types: [publish-docker-image]
env:
IMAGE: lobometalurgico/arunacore
jobs:
publish-docker-image:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get latest arunacore version from github
id: get_version
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ArunaBot/ArunaCore
excludes: draft
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
env:
version: ${{ steps.get_version.outputs.release }}
- name: Generate Test Image
uses: docker/build-push-action@v3
with:
context: .
load: true
tags: ${{ env.IMAGE }}:test
env:
VERSION: ${{ steps.get_version.outputs.release }}
- name: Run Test Image
run: |
docker run --env FINISH_IN_SECONDS=10 --rm ${{ env.IMAGE }}:test
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.IMAGE }}:latest, ${{ env.IMAGE }}:${{ steps.get_version.outputs.release }}
labels: ${{ steps.meta.outputs.labels }}
env:
VERSION: ${{ steps.get_version.outputs.release }}
- name: Update repo description
uses: peter-evans/dockerhub-description@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.IMAGE }}