From 3332a81eaab4cf5007019f217d91ada59350fe18 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 13 Dec 2024 04:06:00 -0500 Subject: [PATCH] feat: initial version --- .github/workflows/build.yaml | 84 ++++++++++++++++++++++++++++++++++++ Dockerfile | 3 ++ LICENSE | 2 +- groups.yaml | 10 +++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yaml create mode 100644 Dockerfile create mode 100644 groups.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..5bb4a19 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,84 @@ +name: Build Portal Images + +on: + push: + branches: ['develop'] + workflow_dispatch: + inputs: + specific_group: + description: 'Build specific group (empty for all)' + required: false + type: string + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + + - id: set-matrix + run: | + GROUPS=$(yq eval -o=json groups.yaml) + if [[ -n "${{ github.event.inputs.specific_group }}" ]]; then + GROUPS=$(echo "$GROUPS" | jq ".groups | {\"${{ github.event.inputs.specific_group }}\": .\"${{ github.event.inputs.specific_group }}\"}") + else + GROUPS=$(echo "$GROUPS" | jq ".groups") + fi + echo "matrix=$(echo "$GROUPS" | jq -c .)" >> $GITHUB_OUTPUT + + build: + needs: prepare + runs-on: ubuntu-latest + strategy: + matrix: + include: ${{ fromJSON(needs.prepare.outputs.matrix) }} + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: true + + # Cache xportal binary install + - name: Cache xportal + id: cache-xportal + uses: actions/cache@v3 + with: + path: ~/go/bin/xportal + key: ${{ runner.os }}-xportal-${{ hashFiles('go.mod', 'go.sum') }} + + # Install xportal if not cached + - if: steps.cache-xportal.outputs.cache-hit != 'true' + name: Install xportal + run: go install go.lumeweb.com/xportal/cmd/xportal@latest + + # Build portal with plugins and cache dependencies + - name: Build portal + run: | + PLUGINS=$(echo '${{ toJSON(matrix.plugins) }}' | jq -r 'join(" --with ")') + xportal build --with $PLUGINS + + - 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: Build and push Docker image + uses: docker/build-push-action@v5 + with: + push: true + context: . + tags: | + ghcr.io/${{ github.repository }}:${{ matrix.group }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..79ffc73 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM alpine:latest +COPY portal /usr/local/bin/portal +ENTRYPOINT ["/usr/local/bin/portal"] \ No newline at end of file diff --git a/LICENSE b/LICENSE index 13064c9..8a24b73 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Lume Web +Copyright (c) 2024 Hammer Technologies LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/groups.yaml b/groups.yaml new file mode 100644 index 0000000..f26e449 --- /dev/null +++ b/groups.yaml @@ -0,0 +1,10 @@ +groups: + core: + plugins: + base: + plugins: + - go.lumeweb.com/portal-plugin-dashboard@latest + standard: + plugins: + - go.lumeweb.com/portal-plugin-dashboard@latest + - go.lumeweb.com/portal-plugin-ipfs@latest \ No newline at end of file