Skip to content

docker

docker #749

Workflow file for this run

name: docker
on:
# Trigger without any parameters a proactive rebuild
workflow_dispatch: {}
workflow_call:
inputs:
tag_name:
required: true
type: string
env:
REGISTRY: ghcr.io
# Will resolve to foundry-rs/foundry
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: build and push
runs-on: Linux-22.04
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 120
steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
# - uses: Swatinem/rust-cache@v2
# with:
# cache-on-failure: true
# - name: Install cross
# id: cross_main
# run: |
# cargo install cross
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login into registry ${{ env.REGISTRY }}
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# # Extract metadata (tags, labels) for Docker
# # https://github.com/docker/metadata-action
# - name: Extract Docker metadata
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
#
# # Creates an additional 'latest' or 'nightly' tag
# # If the job is triggered via cron schedule, tag nightly and nightly-{SHA}
# # If the job is triggered via workflow dispatch and on a master branch, tag branch and latest
# # Otherwise, just tag as the branch name
# - name: Finalize Docker Metadata
# id: docker_tagging
# run: |
# if [[ "${{ github.event_name }}" == 'schedule' ]]; then
# echo "cron trigger, assigning nightly tag"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
# elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
# echo "manual trigger from master/main branch, assigning latest tag"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
# else
# echo "Neither scheduled nor manual release from main branch. Just tagging as branch name"
# echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
# fi
#
# # Log docker metadata to explicitly know what is being pushed
# - name: Inspect Docker Metadata
# run: |
# echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
# echo "LABELS -> ${{ steps.meta.outputs.labels }}"
#
# - name: Build and push foundry image
# run: make DOCKER_IMAGE_NAME=${{ steps.docker_tagging.outputs.docker_tags }} CARGO_TAG_NAME=${{ inputs.tag_name }} PROFILE=maxperf docker-build-push
- name: Cleanup older images
id: cleanup1
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup2
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup3
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup4
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup5
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup6
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup7
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
- name: Cleanup older images
id: cleanup8
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v5
with:
package-name: 'foundry'
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'