Skip to content

Build Rust Stable Image #3

Build Rust Stable Image

Build Rust Stable Image #3

name: Build Rust Stable Image
on:
workflow_dispatch:
inputs:
toolchain:
description: 'Specify the Rust toolchain version'
required: true
default: '1.78.0'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_PREFIX: ci-rust
REGISTRY: ghcr.io/${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check Rust toolchain version exists
id: check-toolchain
uses: actions/setup-rust@v1
with:
rust-version: ${{ github.event.inputs.toolchain }}
continue-on-error: true
- name: Fail if toolchain version does not exist
if: steps.check-toolchain.outcome != 'success'
run: |
echo "Toolchain version ${{ github.event.inputs.toolchain }} does not exist."
exit 1
- name: Log in to the github container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: docker
file: docker/rust_ci.Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}:${{ github.event.inputs.toolchain }}
${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}:latest
build-args: |
DEFAULT_TOOLCHAIN=${{ github.event.inputs.toolchain }}