name: os on: schedule: - cron: '0 5 8,18,28 * *' push: paths: - 'Dockerfile' - 'etc/**' - 'usr/**' - 'repo/**' - '.github/workflows/os.yml' workflow_dispatch: env: REGISTRY: ghcr.io # Vi tvinger navnet til lowercase her for en sikkerheds skyld IMAGE_NAME: ${{ github.repository }} jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write id-token: write steps: - name: Maximize build space uses: AdityaGarg8/remove-unwanted-software@v1 with: remove-dotnet: 'true' remove-android: 'true' remove-haskell: 'true' - name: Get current date id: date run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT - name: Checkout repository uses: actions/checkout@v4 # Vi bruger stadig metadata-action til at generere alle vores tags (inkl. branch) - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=raw,value=latest,enable={{is_default_branch}} type=raw,value=10 type=raw,value=10.${{ steps.date.outputs.date }} # Buildah Login - name: Log into GHCR if: github.event_name != 'pull_request' run: | buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ${{ env.REGISTRY }} # Build med Buildah (Squash er indbygget her) - name: Build image with Buildah id: build-image run: | # Vi tager det første tag fra meta-action som primært build-navn PRIMARY_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n 1) buildah bud \ --label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" \ -t "$PRIMARY_TAG" . echo "primary_tag=$PRIMARY_TAG" >> $GITHUB_OUTPUT # Push alle tags med Buildah - name: Push to GHCR if: github.event_name != 'pull_request' run: | # Loop igennem alle de tags, som metadata-action genererede for tag in $(echo "${{ steps.meta.outputs.tags }}"); do echo "Pushing tag: $tag" buildah push "$tag" done # Cosign (valgfrit - her bruger vi det primære tag til signering) - name: Install cosign if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@v3.3.0 - name: Sign image if: github.event_name != 'pull_request' run: | cosign sign --yes ${{ steps.build-image.outputs.primary_tag }}