146 lines
4.3 KiB
YAML
146 lines
4.3 KiB
YAML
|
|
name: Build All Docker Images
|
||
|
|
|
||
|
|
on:
|
||
|
|
push:
|
||
|
|
branches: [ main, develop ]
|
||
|
|
pull_request:
|
||
|
|
branches: [ main ]
|
||
|
|
release:
|
||
|
|
types: [ published ]
|
||
|
|
workflow_dispatch:
|
||
|
|
|
||
|
|
env:
|
||
|
|
REGISTRY: ghcr.io
|
||
|
|
|
||
|
|
jobs:
|
||
|
|
changes:
|
||
|
|
runs-on: ubuntu-latest
|
||
|
|
outputs:
|
||
|
|
app: ${{ steps.changes.outputs.app }}
|
||
|
|
node: ${{ steps.changes.outputs.node }}
|
||
|
|
steps:
|
||
|
|
- name: Checkout repository
|
||
|
|
uses: actions/checkout@v4
|
||
|
|
|
||
|
|
- name: Check for changes
|
||
|
|
uses: dorny/paths-filter@v2
|
||
|
|
id: changes
|
||
|
|
with:
|
||
|
|
filters: |
|
||
|
|
app:
|
||
|
|
- 'app/**'
|
||
|
|
- '.forgejo/workflows/build-all.yml'
|
||
|
|
node:
|
||
|
|
- 'node/**'
|
||
|
|
- '.forgejo/workflows/build-all.yml'
|
||
|
|
|
||
|
|
build-app:
|
||
|
|
needs: changes
|
||
|
|
if: ${{ needs.changes.outputs.app == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' }}
|
||
|
|
runs-on: ubuntu-latest
|
||
|
|
permissions:
|
||
|
|
contents: read
|
||
|
|
packages: write
|
||
|
|
|
||
|
|
steps:
|
||
|
|
- name: Checkout repository
|
||
|
|
uses: actions/checkout@v4
|
||
|
|
|
||
|
|
- name: Set up Docker Buildx
|
||
|
|
uses: docker/setup-buildx-action@v3
|
||
|
|
|
||
|
|
- name: Log in to Container Registry
|
||
|
|
uses: docker/login-action@v3
|
||
|
|
with:
|
||
|
|
registry: ${{ env.REGISTRY }}
|
||
|
|
username: ${{ github.actor }}
|
||
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||
|
|
|
||
|
|
- name: Extract metadata for App
|
||
|
|
id: meta-app
|
||
|
|
uses: docker/metadata-action@v5
|
||
|
|
with:
|
||
|
|
images: ${{ env.REGISTRY }}/${{ github.repository }}/frp-manager-app
|
||
|
|
tags: |
|
||
|
|
type=ref,event=branch
|
||
|
|
type=ref,event=pr
|
||
|
|
type=semver,pattern={{version}}
|
||
|
|
type=semver,pattern={{major}}.{{minor}}
|
||
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
||
|
|
|
||
|
|
- name: Build and push App Docker image
|
||
|
|
uses: docker/build-push-action@v5
|
||
|
|
with:
|
||
|
|
context: ./app
|
||
|
|
file: ./app/Dockerfile
|
||
|
|
push: true
|
||
|
|
tags: ${{ steps.meta-app.outputs.tags }}
|
||
|
|
labels: ${{ steps.meta-app.outputs.labels }}
|
||
|
|
cache-from: type=gha,scope=app
|
||
|
|
cache-to: type=gha,mode=max,scope=app
|
||
|
|
platforms: linux/amd64,linux/arm64
|
||
|
|
|
||
|
|
build-node:
|
||
|
|
needs: changes
|
||
|
|
if: ${{ needs.changes.outputs.node == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' }}
|
||
|
|
runs-on: ubuntu-latest
|
||
|
|
permissions:
|
||
|
|
contents: read
|
||
|
|
packages: write
|
||
|
|
|
||
|
|
steps:
|
||
|
|
- name: Checkout repository
|
||
|
|
uses: actions/checkout@v4
|
||
|
|
|
||
|
|
- name: Set up Docker Buildx
|
||
|
|
uses: docker/setup-buildx-action@v3
|
||
|
|
|
||
|
|
- name: Log in to Container Registry
|
||
|
|
uses: docker/login-action@v3
|
||
|
|
with:
|
||
|
|
registry: ${{ env.REGISTRY }}
|
||
|
|
username: ${{ github.actor }}
|
||
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||
|
|
|
||
|
|
- name: Extract metadata for Node
|
||
|
|
id: meta-node
|
||
|
|
uses: docker/metadata-action@v5
|
||
|
|
with:
|
||
|
|
images: ${{ env.REGISTRY }}/${{ github.repository }}/home-server-agent
|
||
|
|
tags: |
|
||
|
|
type=ref,event=branch
|
||
|
|
type=ref,event=pr
|
||
|
|
type=semver,pattern={{version}}
|
||
|
|
type=semver,pattern={{major}}.{{minor}}
|
||
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
||
|
|
|
||
|
|
- name: Build and push Node Docker image
|
||
|
|
uses: docker/build-push-action@v5
|
||
|
|
with:
|
||
|
|
context: ./node
|
||
|
|
file: ./node/Dockerfile
|
||
|
|
push: true
|
||
|
|
tags: ${{ steps.meta-node.outputs.tags }}
|
||
|
|
labels: ${{ steps.meta-node.outputs.labels }}
|
||
|
|
cache-from: type=gha,scope=node
|
||
|
|
cache-to: type=gha,mode=max,scope=node
|
||
|
|
platforms: linux/amd64,linux/arm64
|
||
|
|
|
||
|
|
summary:
|
||
|
|
needs: [build-app, build-node]
|
||
|
|
if: always()
|
||
|
|
runs-on: ubuntu-latest
|
||
|
|
steps:
|
||
|
|
- name: Summary
|
||
|
|
run: |
|
||
|
|
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "### App Build: ${{ needs.build-app.result }}" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "### Node Build: ${{ needs.build-node.result }}" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||
|
|
if [ "${{ github.event_name }}" == "release" ]; then
|
||
|
|
echo "### Release Images:" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "- App: \`${{ env.REGISTRY }}/${{ github.repository }}/frp-manager-app:${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
|
||
|
|
echo "- Node: \`${{ env.REGISTRY }}/${{ github.repository }}/home-server-agent:${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
|
||
|
|
fi
|