72a72e6d0e
Gitea Branch PR, SonarQube Analyze, and Merge Workflow / Check and Create PR (push) Has been cancelled
Gitea Branch PR, SonarQube Analyze, and Merge Workflow / Docker Compose Test (push) Has been cancelled
Gitea Branch PR, SonarQube Analyze, and Merge Workflow / PR Merge (push) Has been cancelled
75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
name: Gitea Branch PR, SonarQube Analyze, and Merge Workflow
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- main
|
|
|
|
jobs:
|
|
# Job 1: Check if PR exists and create one if the branch is new
|
|
check-and-create-pr:
|
|
name: Check and Create PR
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: PR list
|
|
id: list-prs
|
|
run: |
|
|
curl -sSL https://dl.gitea.com/tea/main/tea-main-linux-amd64 -o /usr/local/bin/tea
|
|
chmod +x /usr/local/bin/tea
|
|
echo "Listing PRs..."
|
|
tea login add --name gitea-rinoa --url ${{ vars.RINOA_GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }}
|
|
pr_state=$(tea pr ls --repo ${{ github.repository }} --state open --output csv | egrep 'open|closed|merged' | awk -F, '{print $3}' | sed -e 's|"||g')
|
|
echo "pr_state=$(echo ${pr_state})" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create PR
|
|
if: steps.list-prs.outputs.pr_state == 'closed'
|
|
uses: arifer612/Gitea-PR-action@v1.2.0
|
|
with:
|
|
url: ${{ gitea.server_url }}
|
|
token: ${{ secrets.BOT_GITEA_TOKEN }}
|
|
assignee: ${{ gitea.actor }}
|
|
|
|
docker-compose-test:
|
|
name: Docker Compose Test
|
|
needs: [create-pr]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Generate ephemeral .env compose file
|
|
id: generate-env-file-pr
|
|
run: |
|
|
echo "${{ secrets.RINOA_ENV }}" > .env
|
|
|
|
- name: Docker Compose Lint
|
|
uses: yu-ichiro/spin-up-docker-compose-action@v1
|
|
with:
|
|
file: docker-compose.yml
|
|
pull: true
|
|
pull-opts: --dry-run
|
|
up: true
|
|
up-opts: --dry-run -d --remove-orphans
|
|
env:
|
|
DOCKER_HOST: tcp://dockerproxy:2375
|
|
|
|
merge-pr:
|
|
name: PR Merge
|
|
runs-on: ubuntu-latest
|
|
needs: [docker-compose-test]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Tea CLI Setup & PR Merge
|
|
run: |
|
|
curl -sSL https://dl.gitea.com/tea/main/tea-main-linux-amd64 -o /usr/local/bin/tea
|
|
chmod +x /usr/local/bin/tea
|
|
echo "Merging PR..."
|
|
tea login add --name gitea-rinoa --url ${{ vars.RINOA_GITEA_URL }} --user gitea-sonarqube-bot --password "${{ secrets.BOT_GITEA_PASSWORD }}" --token ${{ secrets.BOT_GITEA_TOKEN }}
|
|
echo ${{ gitea.ref_name }}
|
|
pr_index=$(tea pr ls --repo ${{ github.repository }} --state open --fields index,title,head,state --output csv | egrep ${{ gitea.ref_name }} | awk -F, '{print $1}' | sed -e 's|"||g')
|
|
tea pr m --repo ${{ github.repository }} --title "Auto Merge" --message "Merged by ${{ gitea.actor }}" --output table ${pr_index} |