Skip to content

Rename upload to deploy, and fix git commit failure when no changes w… #10

Rename upload to deploy, and fix git commit failure when no changes w…

Rename upload to deploy, and fix git commit failure when no changes w… #10

Workflow file for this run

name: Deploy example projects
on:
push:
branches:
- main
- v2
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mappings:
- mojmap
- yarn
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: object-Object/ci/setup@v0
with:
python-version: "3.11"
python-packages: nox
- name: Copy template
run: nox --keywords ${{ matrix.mappings }} --tags setup
- name: Prepare example project for upload
working-directory: .ctt/${{ matrix.mappings }}
run: |
rm -rf .git
mv .github .github_disabled
echo "This directory would be called \`.github\` in a real project, but it's renamed here to prevent the generated workflows from actually running." >> .github_disabled/README.md
- name: Upload example project
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.mappings }}
path: .ctt/${{ matrix.mappings }}/
deploy:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mappings:
- mojmap
- yarn
concurrency:
group: branch/example/${{ github.ref_name }}/${{ matrix.mappings }}
env:
TARGET_BRANCH: example/${{ github.ref_name }}/${{ matrix.mappings }}
environment:
name: example-projects
url: https://github.com/FallingColors/hexdummy/tree/${{ env.TARGET_BRANCH }}
steps:
# https://github.com/orgs/community/discussions/25305#discussioncomment-8256560
- uses: actions/create-github-app-token@v1
id: token
with:
app-id: ${{ vars.DEPLOYMENT_APP_ID }}
private-key: ${{ secrets.DEPLOYMENT_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.TARGET_BRANCH }}
token: ${{ steps.token.outputs.token }}
- name: Download example project
uses: actions/download-artifact@v4
with:
name: ${{ matrix.mappings }}
# https://github.com/orgs/community/discussions/26560#discussioncomment-3531273
- name: Set Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Deploy example project
run: |
SHORT_SHA=`echo ${{ github.sha }} | cut -c1-10`
git add .
if git commit -m "Deploy ${{ env.TARGET_BRANCH }} from ${SHORT_SHA}"; then
git push
fi