mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 12:13:27 +00:00
ci: add server publisher
This commit is contained in:
parent
fb69ccb265
commit
16294ea128
|
@ -1,5 +1,5 @@
|
|||
name: Install deskop dependencies
|
||||
description: Installs OS-specific dependencies for desktop builds
|
||||
name: Install dependencies
|
||||
description: Installs OS-specific dependencies for builds
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
53
.github/actions/publish-server/action.yml
vendored
Normal file
53
.github/actions/publish-server/action.yml
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
name: Publish Server
|
||||
description: Builds and publishes the docker image for the Spacedrive server
|
||||
inputs:
|
||||
gh_token:
|
||||
description: 'A Github PAT'
|
||||
required: true
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ inputs.gh_token }}
|
||||
|
||||
- name: Build Server
|
||||
shell: bash
|
||||
run: |
|
||||
cargo build --release -p server
|
||||
cp ./target/release/server ./apps/server/server
|
||||
|
||||
- name: Determine image name & tag
|
||||
shell: bash
|
||||
run: |
|
||||
if [ "$GITHUB_EVENT_NAME" == "release" ]; then
|
||||
export IMAGE_TAG=${GITHUB_REF##*/}
|
||||
else
|
||||
export IMAGE_TAG=$(git rev-parse --short "$GITHUB_SHA")
|
||||
fi
|
||||
export GITHUB_REPOSITORY_LOWER=$(echo $GITHUB_REPOSITORY | awk '{print tolower($0)}')
|
||||
export IMAGE_NAME="ghcr.io/$GITHUB_REPOSITORY_LOWER/server"
|
||||
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
|
||||
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
|
||||
echo "Building $IMAGE_NAME:$IMAGE_TAG"
|
||||
- name: Build & push Docker image
|
||||
shell: bash
|
||||
run: |
|
||||
docker build ./apps/server --tag $IMAGE_NAME:$IMAGE_TAG
|
||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
||||
- name: Tag & push image as latest staging image
|
||||
if: github.event_name != 'release'
|
||||
shell: bash
|
||||
run: |
|
||||
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:staging
|
||||
docker push $IMAGE_NAME:staging
|
||||
|
||||
- name: Tag & push image as latest production image
|
||||
if: github.event_name == 'release'
|
||||
shell: bash
|
||||
run: |
|
||||
docker tag $IMAGE_NAME:$IMAGE_TAG $IMAGE_NAME:production
|
||||
docker push $IMAGE_NAME:production
|
39
.github/workflows/ci.yaml
vendored
39
.github/workflows/ci.yaml
vendored
|
@ -70,8 +70,8 @@ jobs:
|
|||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install desktop dependencies
|
||||
uses: ./.github/actions/install-desktop-deps
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/install-deps
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
|
@ -112,8 +112,8 @@ jobs:
|
|||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install desktop dependencies
|
||||
uses: ./.github/actions/install-desktop-deps
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/install-deps
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v1
|
||||
|
@ -157,3 +157,34 @@ jobs:
|
|||
|
||||
- name: Publish artifacts
|
||||
uses: ./.github/actions/publish-desktop-artifacts
|
||||
|
||||
deploy-server:
|
||||
name: Deploy server
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-rust
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v
|
||||
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/install-deps
|
||||
|
||||
- name: Install Rust stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
components: rustfmt, rust-src
|
||||
|
||||
- name: Cache Rust Dependencies
|
||||
uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c
|
||||
with:
|
||||
sharedKey: all-${{ matrix.platform }}
|
||||
|
||||
- name: Publish docker image
|
||||
uses: ./.github/actions/publish-server
|
||||
with:
|
||||
gh_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# TODO: Trigger deploy
|
Loading…
Reference in a new issue