Skip to content

ci: setup sha pushing on ci #26

ci: setup sha pushing on ci

ci: setup sha pushing on ci #26

Workflow file for this run

name: Create and publish a Docker image
on:
push:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
token: ${{ secrets.TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/nanoforge-dev/docs:latest
${{ env.REGISTRY }}/nanoforge-dev/docs:${{ github.sha }}
- name: checkout cloud
uses: actions/checkout@v5
with:
repository: nanoforge-dev/cloud-iac
token: ${{ secrets.TOKEN }}
path: cloud-tmp
- name: install yq and setup git
run: |
pip install yq
git config --global user.name "github-actions[bot]"
git config --global user.email "username@users.noreply.github.com"
- name: Update tag in values.yaml
run: |
cd cloud-tmp
python -m yq -Y --indentless --in-place '.image.tag = "${{ github.sha }}"' kubernetes/nanoforge/docs-override.yml
git add kubernetes/nanoforge/docs-override.yml
git commit -m "Update docs image tag to ${{ github.sha }}"
git push origin main
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true