update build config

This commit is contained in:
sebthom 2023-04-13 18:51:11 +02:00
parent 467ccafd33
commit 252a9dbe3b
1 changed files with 13 additions and 9 deletions

View File

@ -8,9 +8,9 @@ name: Build
on: on:
push: push:
branches: branches: # build all branches
- '**' - '**'
tags-ignore: tags-ignore: # but don't build tags
- '**' - '**'
paths-ignore: paths-ignore:
- '**/*.md' - '**/*.md'
@ -22,20 +22,23 @@ on:
workflow_dispatch: workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ # https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
defaults:
run:
shell: bash
env: env:
DOCKER_IMAGE_REPO: vegardit/gitea-act-runner DOCKER_IMAGE_REPO: vegardit/gitea-act-runner
DOCKER_IMAGE_TAG: latest DOCKER_IMAGE_TAG: latest
TRIVY_CACHE_DIR: ~/.trivy/cache TRIVY_CACHE_DIR: ~/.trivy/cache
defaults:
run:
shell: bash
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Show environment variables
run: env | sort
- name: Git Checkout - name: Git Checkout
uses: actions/checkout@v3 #https://github.com/actions/checkout uses: actions/checkout@v3 #https://github.com/actions/checkout
@ -62,14 +65,15 @@ jobs:
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
TRIVY_GITHUB_TOKEN: ${{ github.token }} TRIVY_GITHUB_TOKEN: ${{ github.token }}
run: | run: |
if [[ $GITHUB_REF_NAME == "main" && $ACT != "true" ]]; then set -eu
if [[ $GITHUB_REF_NAME == "main" && $GITHUB_EVENT_NAME != "pull_request" && ${ACT:-} != "true" ]]; then
export DOCKER_PUSH=1 export DOCKER_PUSH=1
echo "$DOCKER_REGISTRY_TOKEN" | docker login -u="$DOCKER_REGISTRY_USERNAME" "$DOCKER_REGISTRY" --password-stdin echo "$DOCKER_REGISTRY_TOKEN" | docker login -u="$DOCKER_REGISTRY_USERNAME" "$DOCKER_REGISTRY" --password-stdin
fi fi
bash build-image.sh bash build-image.sh
- name: Publish Docker image to GH registry - name: Publish Docker image to GH registry
if: ${{ github.ref_name == 'main' && !env.ACT }} # https://github.com/nektos/act#skipping-steps if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
run: | run: |
set -eux set -eux
@ -80,7 +84,7 @@ jobs:
- name: Delete untagged images - name: Delete untagged images
uses: actions/github-script@v6 uses: actions/github-script@v6
if: ${{ github.ref_name == 'main' && !env.ACT }} # https://github.com/nektos/act#skipping-steps if: ${{ github.ref_name == 'main' && github.event_name != 'pull_request' && !env.ACT }} # https://github.com/nektos/act#skipping-steps
with: with:
github-token: ${{ secrets.GHA_DELETE_PACKAGES }} github-token: ${{ secrets.GHA_DELETE_PACKAGES }}
script: | script: |