#!groovy

pipeline {
    agent {
        label 'linux'
    }
    stages {
        stage('NPM Install') {
            when {
                beforeAgent true;
                branch 'main'
            }
            steps {
                sh 'npm clean-install'
            }
        }
        stage('Compile Adblock List') {
            when {
                beforeAgent true;
                branch 'main'
            }
            steps {
                // sh 'npm run compile'
                sh 'rm test.txt'
            }
        }
        stage('git push') {
            when {
                beforeAgent true;
                branch 'main'
            }
            steps {
                withCredentials([
                    gitUsernamePassword(credentialsId: 'gitea-jenkins-user-token')
                ]) {
                    sh '''
                        git checkout main
                        git add .
                        git commit -m "Update Compiled Adblock List"
                        git push
                    '''
                }
            }
        }
    }
}
