Created
January 21, 2022 01:23
-
-
Save kawzar/8baa982fbb764d8ac72ec23eafb366c2 to your computer and use it in GitHub Desktop.
Unity build and copy to FTP workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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