update supervosrd.conf #145
Workflow file for this run
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
on: | |
push: | |
branches: | |
- "*" | |
- "!stable" | |
name: π₯ Test Workflow | |
jobs: | |
laravel-test: | |
name: π Laravel Test | |
runs-on: ubuntu-latest | |
environment: testing | |
services: | |
mariadb: | |
image: mysql:8.0 | |
env: | |
MYSQL_ROOT_PASSWORD: testing | |
MYSQL_DATABASE: testing | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: π Git checkout | |
uses: actions/checkout@v4 | |
- name: π Make sure repository is latest | |
run: git fetch --prune --unshallow | |
- name: π Set up php | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.2" | |
- name: π οΈ Install dependencies | |
run: composer install --no-interaction | |
- name: π Create environment | |
run: cp .env.example .env | |
- name: π Generate app key | |
run: php artisan key:generate | |
- name: π½ Set up database | |
run: php artisan migrate --seed --env=testing | |
- name: πΊοΈ Check routes | |
run: php artisan route:clear && php artisan route:list | |
- name: β Run php tests | |
run: vendor/bin/phpunit | |
create-pr: | |
needs: [laravel-test] | |
name: π Create Pull Request | |
runs-on: ubuntu-latest | |
environment: testing | |
steps: | |
- name: π₯ Checkout code | |
uses: actions/checkout@v4 | |
- name: π Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: π Create PR | |
run: | | |
# Set up authentication | |
echo "${{ secrets.PERSONAL_TOKEN }}" >> token.txt | |
gh auth login --with-token < token.txt | |
rm -rf token.txt | |
# Get the current branch name | |
CURRENT_BRANCH=$(echo "${GITHUB_REF}" | awk -F'/' '{print $3}') | |
# Check if a pull request already exists | |
EXISTING_PR=$(gh pr list --state open --base stable --head "${CURRENT_BRANCH}" --json number | jq -r '.[0].number') | |
# If a pull request exists, exit the workflow | |
if [[ "$EXISTING_PR" == null ]]; then | |
# Get the current date and time in the specified format | |
CURRENT_DATE=$(TZ='Asia/Jakarta' date +'%d-%m-%Y %H:%M') | |
# Create a pull request with date and time in the title | |
PR_TITLE="[$CURRENT_DATE] $CURRENT_BRANCH - Request merge $CURRENT_BRANCH to stable branch" | |
git fetch origin stable | |
fetch_exit_code=$? | |
git fetch origin "${CURRENT_BRANCH}" | |
fetch_branch_exit_code=$? | |
if [ $fetch_exit_code -ne 0 ]; then | |
echo "Error fetching 'stable' branch from origin." | |
exit 0 # Script continues despite the error | |
fi | |
if [ $fetch_branch_exit_code -ne 0 ]; then | |
echo "Error fetching '${CURRENT_BRANCH}' branch from origin." | |
exit 0 # Script continues despite the error | |
fi | |
# Check if the branch exists in the remote repository | |
if ! git ls-remote --exit-code origin "${CURRENT_BRANCH}"; then | |
echo "'${CURRENT_BRANCH}' branch does not exist in the remote repository. $?" | |
fi | |
if git diff --quiet origin/stable origin/"${CURRENT_BRANCH}"; then | |
echo "No commits between branches. Skipping pull request creation." | |
else | |
gh pr create \ | |
--base stable \ | |
--head "${CURRENT_BRANCH}" \ | |
--title "${PR_TITLE}" \ | |
--body "Automated pull request from ${CURRENT_BRANCH} to stable branch" | |
fi | |
else | |
echo "Pull request ${CURRENT_BRANCH} already exists ${EXISTING_PR}. Skipping PR creation." | |
exit 0 | |
fi |