Skip to content

Docker

Docker #2

Workflow file for this run

# https://codingpackets.com/blog/rust-binary-and-docker-releases-using-github-actions/#release-workflow
# https://twitter.com/mjovanc/article/1757733086236643419
# https://cjwebb.com/rust-github-actions-on-arm/
name: "Docker"
permissions:
contents: "write"
on:
workflow_run:
workflows: [ "Test" ]
types:
- "completed"
branches:
- master
- dev
- 'release/**'
env:
GITHUB_REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
with:
submodules: recursive
- name: Get abbreviated SHA hash of the commit
uses: benjlevesque/short-sha@v2.2
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build release artifact
uses: actions-rs/cargo@v1
with:
command: build
args: --release --timings --workspace
- name: Save build timings
uses: actions/upload-artifact@v3
with:
name: release build timings
path: target/cargo-timings/cargo-timing.html
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.SHA }}