Skip to content

Merge pull request #17 from solid-software/upd-worklog-badge #38

Merge pull request #17 from solid-software/upd-worklog-badge

Merge pull request #17 from solid-software/upd-worklog-badge #38

name: Generate a Flutter application template
on: [push]
permissions:
contents: write
# if condition must be changed to github.repository != 'solid-software/flutter_project_template'
jobs:
create-project:
if: ${{ github.repository != 'solid-software/flutter_project_template' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
ref: ${{ github.head_ref }}
- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
shell: bash
- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash
- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
shell: bash
- run: |
email=$(curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/users/${{ env.REPOSITORY_OWNER }} \
| jq -r '.email')
if [ $email == null ]; then
echo "REPO_ORGANIZATION=com.${{ env.REPOSITORY_OWNER }} >> $GITHUB_ENV"
exit 0;
fi
domain=$(echo $email | rev | cut -d\@ -f1 | rev)
secondlevel_domain=$(echo $domain | cut -d. -f1)
toplevel_domain=$(echo $domain | cut -d. -f2)
echo "REPO_ORGANIZATION=${toplevel_domain}.${secondlevel_domain}" >> $GITHUB_ENV
- name: Get Flutter SDK
uses: subosito/flutter-action@v1
with:
channel: 'stable'
- name: Create the project
run: |
organization="${{ env.REPO_ORGANIZATION }}.${{ env.REPOSITORY_NAME }}"
repo_name="${{ env.REPOSITORY_NAME }}"
echo "Creating the project with org ${organization} name ${repo_name}"
flutter create . \
--org="$organization" \
--project-name="${repo_name}"
flutter pub add --dev solid_lints
flutter pub get
- name: Self-destruct
run: |
rm .github/workflows/generate-template.yaml
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Ready to clone and code."
# commit_options: '--amend --no-edit'
push_options: --force