Docker Build and Push SSHbox Image #19
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: Docker Build and Push SSHbox Image | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
tags: | |
- "v*.*.*" | |
paths: | |
- "sshbox/**" | |
- ".github/workflows/sshbox.yml" | |
pull_request: | |
branches: | |
- main | |
- dev | |
schedule: # automatic updates “At 00:00.” Every day -- https://crontab.guru/#0_0_*_*_* | |
- cron: "0 0 * * *" | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/hyperboliclabs/hyper-dos/sshbox | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
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 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# Setting up Docker Buildx with docker-container driver is required | |
# at the moment to be able to use a subdirectory with Git context | |
- name: Set up Docker Buildx | |
# we don't need to run the usual 'checkout' action, buildx takes care of it. | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
# https://github.com/marketplace/actions/docker-login | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: "{{defaultContext}}:sshbox" | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |