Publish Docker image #55
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: Publish Docker image | |
on: | |
push: | |
branches: [main] | |
schedule: | |
# Every Monday at 02:00 UTC | |
- cron: "0 2 * * 1" | |
workflow_dispatch: | |
inputs: | |
rust_toolchain: | |
description: "Rust toolchain" | |
required: true | |
default: "nightly" | |
env: | |
IMAGE_NAME: ghcr.io/vita-rust/vitasdk-rs | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest | |
- name: Build Docker image | |
id: build | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: "RUST_TOOLCHAIN=${{ github.event.inputs.rust_toolchain || 'nightly' }}" | |
- name: Test built image | |
run: | | |
docker run \ | |
--mount type=bind,source="$(pwd)"/test.sh,target=/test.sh,readonly \ | |
${{ steps.build.outputs.imageid }} \ | |
/test.sh | |
- name: Push image to ghcr | |
run: | | |
docker push --all-tags ${{ env.IMAGE_NAME }} |