Skip to content

Update ci.yml

Update ci.yml #17

Workflow file for this run

name: "Swift 6 Module Template CI"
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
permissions:
contents: write
actions: write
jobs:
test-configure-script:
name: Test configure.swift script and generate project
runs-on: macos-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Test configure script with environment variables
env:
SMT_XXPROJECTXNAMEXX: "TestModule"
SMT_ORGANIZATION_NAME: "Test Organization"
SMT_COM_AN_ORGANIZATION_IDENTIFIER: "com.test.organization"
SMT_AUTHOR_NAME: "Test Author"
SMT_TODAYS_DATE: "January 1, 2024"
SMT_TODAYS_YEAR: "2024"
SMT_GITHUB_USERNAME: "testuser"
run: |
./configure.swift
ls -la OUTPUT/
- name: Verify generated project structure
run: |
cd OUTPUT/TestModule
ls -la
test -f Package.swift
test -f README.md
test -f LICENSE
test -d Sources/TestModule
test -d Tests/TestModuleTests
test -d .github/workflows
- name: Upload generated project as artifact
uses: actions/upload-artifact@v4
with:
name: generated-project
path: OUTPUT/TestModule/
include-hidden-files: true
deploy-generated-project:
name: Deploy generated project to test branch
needs: test-configure-script
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download generated project
uses: actions/download-artifact@v4
with:
name: generated-project
path: generated/
- name: Push to production branch
run: |
cd generated
git init
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add .
git commit -m "Generated project from main commit ${{ github.sha }}"
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push -f origin HEAD:production