diff --git a/clone/action.yml b/clone/action.yml new file mode 100644 index 0000000..86e0d91 --- /dev/null +++ b/clone/action.yml @@ -0,0 +1,41 @@ +name: "Clone OTP" +description: "Build docker image with docker" + +inputs: + repository: # id of input + description: "Repository path" + required: true + branch: + description: "Repository Branch" + required: true + default: "master" + ssh-private-key: + description: "SSH private key for cloning" + required: true +runs: + using: "composite" + steps: + - name: Building + uses: https://git.binom.pw/otp/devops/proxy@main + with: + ssh-private-key: ${{ inputs.ssh-private-key }} + - name: "Configure http proxy" + shell: bash + run: | + mkdir -p ~/.ssh + echo "$SSH_KEY" > ~/.ssh/my_key + cat > ~/.ssh/config << 'EOF' + Host bitbucket.isb + HostName bitbucket.isb + User git + IdentityFile ~/.ssh/my_key + ProxyCommand socat - PROXY:192.168.76.142:%h:%p,proxyport=8077 + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + IdentitiesOnly yes + EOF + chmod 600 ~/.ssh/config + chmod 600 ~/.ssh/my_key + - name: Cloning + run: | + GIT_TERMINAL_PROMPT=0 git clone --single-branch --branch "${{ inputs.branch }}" "ssh://git@bitbucket.isb:443/${{ inputs.repository }}.git" . diff --git a/config-gradle/action.yml b/config-gradle/action.yml new file mode 100644 index 0000000..838dc7e --- /dev/null +++ b/config-gradle/action.yml @@ -0,0 +1,80 @@ +name: "Clone OTP" +description: "Build docker image with docker" + +runs: + using: "composite" + steps: + - name: "Config gradle" + shell: bash + run: | + mkdir -p ~/.gradle + cat > ~/.gradle/init.gradle.kts << 'EOF' + import java.net.URI + + val OTP_REPO_PREFIX = "https://nexus.isb/repository/" + val MAVEN_CENTRAL = "https://repo.maven.apache.org/maven2/" + val GRADLE_PLUGIN_REPOSITORY = "https://plugins.gradle.org/m2/" + + fun replaceRepository(repo: ArtifactRepository) { + if (repo !is MavenArtifactRepository) { + return + } + val sourceUrl = repo.url + when { + repo.url == URI("${OTP_REPO_PREFIX}central-mvn-proxy/") -> repo.url = URI(MAVEN_CENTRAL) + repo.url == URI("${OTP_REPO_PREFIX}pluginsgradle-mvn-proxy/") -> + repo.url = URI(GRADLE_PLUGIN_REPOSITORY) + repo.url.toString().startsWith(OTP_REPO_PREFIX) -> { + repo.url = + URI( + "http://192.168.76.117/repository/${repo.url.toString().removePrefix(OTP_REPO_PREFIX)}" + ) + repo.isAllowInsecureProtocol = true + } + } + if (sourceUrl != repo.url) { + repo.isAllowInsecureProtocol = true + repo.credentials.username = "" + repo.credentials.password = "" + println("$sourceUrl => ${repo.url}") + } + } + + val LOCAL_REPOSITORY = "file:/home/${System.getProperty("user.name")}/.m2/repository/" + + gradle.settingsEvaluated { + pluginManagement + .repositories + .filterIsInstance() + .filter { + it.url == URI("https://nexus.isb/repository/pluginsgradle-mvn-proxy/") || + it.url == URI("http://repo.xx/otp-pluginsgradle-mvn-proxy/") + } + .forEach { + pluginManagement.repositories.remove(it) + pluginManagement.repositories.add(0, it) + } + + pluginManagement + .repositories + .filterIsInstance() + .filter { it.url == URI(LOCAL_REPOSITORY) } + .forEach { + pluginManagement.repositories.remove(it) + pluginManagement.repositories.add(0, it) + } + } + + gradle.beforeSettings { + pluginManagement.repositories.configureEach { replaceRepository(this) } + dependencyResolutionManagement.repositories.configureEach { replaceRepository(this) } + allprojects { + repositories.configureEach { replaceRepository(this) } + } + } + EOF + - name: 'Cleanup' + if: always() + shell: bash + run: | + rm -rf ~/.gradle/init.gradle.kts \ No newline at end of file diff --git a/proxy/action.yml b/proxy/action.yml new file mode 100644 index 0000000..3e9d99f --- /dev/null +++ b/proxy/action.yml @@ -0,0 +1,34 @@ +name: "Clone OTP" +description: "Build docker image with docker" + +inputs: + ssh-private-key: + description: "SSH private key for cloning" + required: true +runs: + using: "composite" + steps: + - name: "Configure proxy" + shell: bash + run: | + mkdir -p ~/.ssh + echo "${{ inputs.ssh-private-key }}" > ~/.ssh/my_key + cat > ~/.ssh/config << 'EOF' + Host bitbucket.isb + HostName bitbucket.isb + User git + IdentityFile ~/.ssh/my_key + ProxyCommand socat - PROXY:192.168.76.142:%h:%p,proxyport=8077 + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + IdentitiesOnly yes + EOF + chmod 600 ~/.ssh/config + chmod 600 ~/.ssh/my_key + + - name: 'Cleanup' + if: always() + shell: bash + run: | + rm -rf ~/.ssh/config + rm -rf ~/.ssh/my_key diff --git a/setup-gradle/action.yml b/setup-gradle/action.yml new file mode 100644 index 0000000..b992b63 --- /dev/null +++ b/setup-gradle/action.yml @@ -0,0 +1,11 @@ +name: "Clone OTP" +description: "Build docker image with docker" + +runs: + using: "composite" + steps: + - name: "Setup gradle project" + shell: bash + run: | + sed -i 's|distributionUrl=https://nexus.isb/repository/gradleorg-raw-proxy|distributionUrl=https://services.gradle.org/distributions|g' ./gradle/wrapper/gradle-wrapper.properties + chmod +x ./gradlew \ No newline at end of file