Skip to content

fix: merge-ci on delete branch #14

fix: merge-ci on delete branch

fix: merge-ci on delete branch #14

Workflow file for this run

name: Merge CI
# This workflow is triggered on pull request to the repository.
# Run this script when PR and status is closed
on:
pull_request:
types: [ closed ]
jobs:
build:
# This job will run on ubuntu virtual machine
runs-on: ubuntu-latest
steps:
# Setup Java environment in order to build the Android app.
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17'
# Setup the flutter environment.
- uses: subosito/flutter-action@v2
with:
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
# flutter-version: '1.12.x' # you can also specify exact version of flutter
# Get flutter dependencies.
- name: Running flutter pub get
run: flutter pub get
# Formatting code
- name: Running flutter format
run: dart format lib/
# Get current branch
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
# Check modified files
- name: Check for modified files
id: git-check
run: echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
# Push code changes
- name: Push changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name 'Lzyct-Bot'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch
git checkout ${{ steps.branch-name.outputs.current_branch }}
git commit -am "clean: apply formatting changes"
git push
# Build apk.
# - name: Build apk file
# run: flutter build apk --flavor stg -t lib/main_stg.dart
#
# # Upload generated apk to the artifacts.
# - name: Uploading apk file
# uses: actions/upload-artifact@v1
# with:
# name: staging-apk
# path: build/app/outputs/flutter-apk/app-stg-release.apk
- name: Delete branch if merged
uses: actions/github-script@v5
with:
script: |
github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/${context.payload.pull_request.head.ref}`,
})}