Skip to content

Branch CI for add-state by peterdudfield #105

Branch CI for add-state by peterdudfield

Branch CI for add-state by peterdudfield #105

Workflow file for this run

name: Branch CI
run-name: Branch CI for ${{ github.ref_name }} by ${{ github.actor }}
on:
push:
branches-ignore: [ main ]
paths-ignore: ['README.md']
# Registry for storing Container images
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
branch_ci:
uses: openclimatefix/.github/.github/workflows/branch_ci.yml@main
with:
enable_typechecking: false
enable_linting: false
test_python_versions: '["3.12"]'
tests_folder: 'tests'
containerfile: 'None'
secrets: inherit
# Job for building container image
# * Builds and pushes an OCI Container image to the registry defined in the environment variables
# * Only runs if branch_ci pass
# Need to add secret to docker file
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: ["branch_ci"]
if: ${{ github.repository_owner == 'openclimatefix' && github.event_name != 'pull_request' }}
steps:
# Do a non-shallow clone of the repo to ensure tags are present
# * This allows setuptools-git-versioning to automatically set the version
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and populate secrets.toml file
env:
APP_PASSWORD: ${{ secrets.APP_PASSWORD }}
run: |
touch src/.streamlit/secrets.toml
echo "password = \"$APP_PASSWORD\"" >> src/.streamlit/secrets.toml
# Tag the built image according to the event type
# The event is a branch commit, so use the commit sha
- name: Extract metadata (tags, labels) for Container
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: type=ref,event=branch
# Build and push the Container image to the registry
# * Creates a multiplatform-aware image
# * Pulls build cache from the registry
- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache