Skip to content

Docker image

Docker image #1670

Workflow file for this run

name: Docker image
on:
push:
branches: ['**']
tags: ['v*.*.*']
pull_request:
branches: [main]
pull_request_target:
types: [labeled]
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
jobs:
build_and_push:
runs-on: ubuntu-20.04
name: Create docker image
steps:
- uses: actions/checkout@v4
- run: docker version
- run: docker info
- run: docker system df -v
- uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# https://github.com/docker/metadata-action
- uses: docker/metadata-action@v5.5.1
id: docker_meta
with:
images: |
ghcr.io/asaaki/hello-world-docker-action
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=sha
type=edge,branch=main
type=ref,event=pr
type=ref,event=branch
type=schedule,pattern=nightly
- uses: docker/login-action@v3.1.0
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_PAT }}
- uses: docker/setup-buildx-action@v3.3.0
- uses: docker/build-push-action@v5.3.0
with:
context: .
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
self_test:
needs: [build_and_push]
runs-on: ubuntu-20.04
name: Self tests the hello world docker action
steps:
- uses: actions/checkout@v4
- name: Hello world action step
id: hello # for use in step below
uses: ./.image
with:
greetee: "${{ secrets.HELLO_SECRET_NAME }}"
github_token: ${{ secrets.GHCR_PAT }}
- name: Get the output time
run: echo "The time was ${{ steps.hello.outputs.time }}"