UA-Bot/.github/workflows/docker-image.yml

58 lines
1.6 KiB
YAML
Raw Normal View History

2023-07-13 07:41:54 +00:00
# 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: Create and publish a Docker image on push
2023-07-12 21:17:02 +00:00
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
2023-07-13 07:41:54 +00:00
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
2023-07-12 21:17:02 +00:00
2023-07-13 07:41:54 +00:00
jobs:
build-and-push-image:
2023-07-12 21:17:02 +00:00
runs-on: ubuntu-latest
2023-07-13 07:41:54 +00:00
permissions:
contents: read
packages: write
2023-07-12 21:17:02 +00:00
steps:
2023-07-13 07:41:54 +00:00
- name: Checkout repository
uses: actions/checkout@v3
2023-07-13 08:49:28 +00:00
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
2023-07-13 07:41:54 +00:00
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
2023-07-13 08:49:28 +00:00
2023-07-13 07:41:54 +00:00
- name: Build and push Docker image
2023-07-13 08:44:18 +00:00
uses: docker/build-push-action@v4
2023-07-13 07:41:54 +00:00
with:
context: .
push: true
2023-07-13 08:41:47 +00:00
platforms: linux/amd64,linux/arm64
2023-07-13 07:41:54 +00:00
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}