typo i logg melding #313
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# github actions | |
name: Publish to ghcr | |
on: | |
push: | |
branches: | |
- main | |
- feat/** | |
paths-ignore: | |
- '**.md' | |
workflow_dispatch: | |
permissions: | |
actions: write | |
contents: read | |
id-token: write | |
packages: write | |
env: | |
IMAGE_NAME: "ghcr.io/${{ github.repository }}" | |
jobs: | |
"build": | |
name: "build" | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: GitHubSecurityLab/actions-permissions/monitor@v1 | |
with: | |
config: ${{ vars.PERMISSIONS_CONFIG }} | |
- uses: actions/[email protected] | |
- name: "Add sha to environment variable" | |
env: | |
FULL_SHA: "${{github.sha}}" | |
REF: "${{github.ref}}" | |
run: | | |
TAG=$(git log -1 --pretty=%ad --date=format:%Y-%m-%d)-$(git log --pretty=format:'%h' -n 1) | |
branch=$(echo $REF | cut -c12-) | |
if [ $branch = main ] | |
then | |
echo "IMAGE=$IMAGE_NAME:$TAG" >> $GITHUB_ENV | |
else | |
echo "IMAGE=$IMAGE_NAME-$branch:$TAG" >> $GITHUB_ENV | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.IMAGE }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |