Build Docker Image #1
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: Build Docker Image | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ main ] | |
tags: | |
- v* | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
repository_dispatch: | |
types: | |
- webhook | |
jobs: | |
k8s: | |
name: RemoteDockerImage | |
runs-on: self-hosted | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@master | |
with: | |
install: true | |
- name: Docker Login | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/${{ github.repository_owner }}/base/rethinkdb | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule,pattern=nightly | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Build Image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./init/ | |
file: ./init/Dockerfile | |
push: true | |
pull: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
builder: ${{ steps.buildx.outputs.name }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |