mirror of
https://github.com/Kizuren/uLinkShortener.git
synced 2025-12-21 21:16:17 +01:00
Attempt to fix workflow file
This commit is contained in:
parent
988b0f25e6
commit
9bbb924f48
1 changed files with 74 additions and 51 deletions
125
.github/workflows/build.yml
vendored
125
.github/workflows/build.yml
vendored
|
|
@ -22,12 +22,9 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- uses: oven-sh/setup-bun@v1
|
- uses: oven-sh/setup-bun@v1
|
||||||
|
|
||||||
- name: Install and update lockfile
|
- name: Install and update lockfile
|
||||||
run: bun install
|
run: bun install
|
||||||
|
|
||||||
- name: Commit and push updated lockfile
|
- name: Commit and push updated lockfile
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
|
|
@ -36,57 +33,83 @@ jobs:
|
||||||
git commit -m "chore: update lockfile (auto-fix for Dependabot PR)" || exit 0
|
git commit -m "chore: update lockfile (auto-fix for Dependabot PR)" || exit 0
|
||||||
git push
|
git push
|
||||||
|
|
||||||
# Build and push Docker image
|
# Build and push Docker image for Dependabot PRs
|
||||||
build:
|
build_dependabot:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [update-lockfile]
|
needs: update-lockfile
|
||||||
# Run this job if:
|
if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'dependabot/')
|
||||||
# 1. This is NOT a PR (like push to main or release)
|
|
||||||
# 2. OR this is a PR but NOT from Dependabot
|
|
||||||
# 3. OR this is a Dependabot PR AND the update-lockfile job completed successfully
|
|
||||||
if: |
|
|
||||||
github.event_name != 'pull_request' ||
|
|
||||||
(github.event_name == 'pull_request' && !startsWith(github.head_ref, 'dependabot/')) ||
|
|
||||||
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'dependabot/') && needs.update-lockfile.result == 'success')
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'dependabot/') && github.head_ref || '' }}
|
ref: ${{ github.head_ref }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Set image metadata
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=tag
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=sha,format=short
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: false
|
||||||
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
# Build and push Docker image for all other events
|
||||||
uses: docker/setup-buildx-action@v3
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
- name: Login to GitHub Container Registry
|
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !startsWith(github.head_ref, 'dependabot/'))
|
||||||
uses: docker/login-action@v3
|
permissions:
|
||||||
with:
|
contents: read
|
||||||
registry: ghcr.io
|
packages: write
|
||||||
username: ${{ github.actor }}
|
steps:
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
- name: Set image metadata
|
- name: Set up Docker Buildx
|
||||||
id: meta
|
uses: docker/setup-buildx-action@v3
|
||||||
uses: docker/metadata-action@v5
|
- name: Login to GitHub Container Registry
|
||||||
with:
|
uses: docker/login-action@v3
|
||||||
images: ghcr.io/${{ github.repository }}
|
with:
|
||||||
tags: |
|
registry: ghcr.io
|
||||||
type=ref,event=tag
|
username: ${{ github.actor }}
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
type=sha,format=short
|
- name: Set image metadata
|
||||||
type=ref,event=branch
|
id: meta
|
||||||
type=ref,event=pr
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
- name: Build and push Docker image
|
images: ghcr.io/${{ github.repository }}
|
||||||
uses: docker/build-push-action@v6
|
tags: |
|
||||||
with:
|
type=ref,event=tag
|
||||||
context: .
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
file: ./Dockerfile
|
type=sha,format=short
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
type=ref,event=branch
|
||||||
platforms: linux/amd64, linux/arm64/v8
|
type=ref,event=pr
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
- name: Build and push Docker image
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue