Skip to content

Instantly share code, notes, and snippets.

@kawzar
Created January 21, 2022 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kawzar/8baa982fbb764d8ac72ec23eafb366c2 to your computer and use it in GitHub Desktop.
Save kawzar/8baa982fbb764d8ac72ec23eafb366c2 to your computer and use it in GitHub Desktop.
Unity build and copy to FTP workflow
name: Build project
on:
workflow_dispatch:
pull_request:
types: [closed]
jobs:
buildForWebGL:
name: Build for WebGL
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- name: Cache
uses: actions/cache@v2
with:
path: Library
key: Library-WebGL
restore-keys: Library-
- name: Start Build
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
targetPlatform: WebGL
versioning: Semantic
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: build-${{ steps.date.outputs.date }}-${{ github.run_id }}
path: build/WebGL
uploadToFTP:
name: Upload to FTP
runs-on: ubuntu-latest
needs: buildForWebGL
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Download build artifact
uses: actions/download-artifact@v1
with:
name: build-${{ steps.date.outputs.date }}-${{ github.run_id }}
path: build/WebGL
- name: Upload via FTP
uses: isthatcentered/dist-to-ftp@master
with:
host: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USER }}
password: ${{ secrets.FTP_PASSWORD }}
path: build/WebGL
into: ${{steps.extract_branch.outputs.branch}}\${{ steps.date.outputs.date }}
discordMessage:
name: Send message to discord
runs-on: ubuntu-latest
needs: uploadToFTP
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Send Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@master
with:
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} has been deployed. New Build URL: https://example.com/builds/${{steps.extract_branch.outputs.branch}}/${{ steps.date.outputs.date }}/WebGL'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment