Created
June 9, 2024 18:09
-
-
Save shanerbaner82/bfd5d67306122bf6638c0a8e862207bf to your computer and use it in GitHub Desktop.
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: Setup Laravel application and push to GitHub | |
hosts: localhost | |
gather_facts: false | |
vars: | |
ansible_python_interpreter: /usr/bin/python3 | |
tasks: | |
# - name: Run composer update | |
# command: composer update | |
# args: | |
# chdir: /app | |
- name: Initialize a new Git repository | |
command: git init | |
args: | |
chdir: /app | |
- name: Add all files to the repository | |
command: git add . | |
args: | |
chdir: /app | |
- name: Set Git user email from .env | |
command: git config user.email "{{ lookup('env', 'GITHUB_USER_EMAIL') }}" | |
args: | |
chdir: /app | |
- name: Set Git user name from .env | |
command: git config user.name "{{ lookup('env', 'GITHUB_USER_NAME') }}" | |
args: | |
chdir: /app | |
- name: Commit the files | |
command: git commit -m "Initial commit" | |
args: | |
chdir: /app | |
- name: Create a new GitHub repository | |
shell: gh repo create "{{ lookup('env', 'GITHUB_REPO_NAME') }}" --public --source=/app --remote=origin --push | |
args: | |
chdir: /app | |
environment: | |
GITHUB_TOKEN: "{{ lookup('env', 'GITHUB_TOKEN') }}" | |
register: gh_output | |
- name: Display GitHub repository creation result | |
debug: | |
msg: "{{ gh_output.stdout }}" | |
- name: Create a new GitHub project | |
shell: gh project create --title "{{ lookup('env', 'GITHUB_REPO_NAME') }}" --owner @me --format json | |
environment: | |
GITHUB_TOKEN: "{{ lookup('env', 'GITHUB_TOKEN') }}" | |
register: project_output | |
- name: Display GitHub project creation result | |
debug: | |
msg: "{{ project_output.stdout }}" | |
- name: Add a task to the GitHub project | |
shell: > | |
gh project item-create 22 | |
--owner @me | |
--title "Install Filament" | |
--body "Install the Filament package for the application" | |
environment: | |
GITHUB_TOKEN: "{{ lookup('env', 'GITHUB_TOKEN') }}" | |
register: task_output | |
- name: Link the project to the repo | |
shell: > | |
gh project link 22 | |
--owner "{{ lookup('env', 'GITHUB_USERNAME') }}" | |
--repo "{{ lookup('env', 'GITHUB_REPO_NAME') }}" | |
environment: | |
GITHUB_TOKEN: "{{ lookup('env', 'GITHUB_TOKEN') }}" | |
register: task_output | |
- name: Display task creation result | |
debug: | |
msg: "{{ task_output.stdout }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment