Skip to content

Commit

Permalink
Create GitHub Action for deploying to Artifactory
Browse files Browse the repository at this point in the history
This commit contains a GitHub Action for deploying to Artifactory. It
is heavily based on the source of the existing Concourse Artifactory
Resource (https://github.com/spring-io/artifactory-resource). It
provides for GitHub Actions functionality that is equivalent to the
Concourse resource's out support.
  • Loading branch information
wilkinsona committed Mar 8, 2024
0 parents commit dcac477
Show file tree
Hide file tree
Showing 81 changed files with 6,711 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI
on:
- push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
build:
name: 'Build'
runs-on: 'ubuntu-latest'
steps:
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'liberica'
java-version: 17
- name: Check out code
uses: actions/checkout@v4
- name: Set up Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5
with:
cache-read-only: false
- name: Build
id: build
run: ./gradlew build
integration-test:
runs-on: ubuntu-latest
name: 'Integration test'
services:
artifactory:
image: docker.bintray.io/jfrog/artifactory-oss:7.12.10
ports:
- 8081:8081
steps:
- name: Check out action
uses: actions/checkout@v4
- name: Create artifacts to deploy
run: |
mkdir -p deployment-repository/com/example/module-a/1.0.0-SNAPSHOT
touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar
touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom
touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar
touch deployment-repository/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar
mkdir -p deployment-repository/com/example/module-b/1.0.0-SNAPSHOT
touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar
touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom
touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar
touch deployment-repository/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar
- name: Run action
uses: ./
id: run
with:
uri: 'http://artifactory:8081/artifactory'
username: 'admin'
password: 'password'
build-name: ${{github.action}}
repository: 'example-repo-local'
folder: 'deployment-repository'
signing-key: ${{ secrets.INTEGRATION_TEST_SIGNING_KEY }}
signing-passphrase: ${{ secrets.INTEGRATION_TEST_SIGNING_PASSPHRASE }}
artifact-properties: |
:/**/*.jar:not-jar=true
/**/module-a-*::a=alpha
/**/module-b-*::b=bravo,c=charlie
env:
ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
- name: Download artifacts
run: |
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.jar.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT.pom.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-sources.jar.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-a/1.0.0-SNAPSHOT/module-a-1.0.0-SNAPSHOT-javadoc.jar.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.jar.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT.pom.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-sources.jar.asc
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar
wget http://admin:password@localhost:8081/artifactory/example-repo-local/com/example/module-b/1.0.0-SNAPSHOT/module-b-1.0.0-SNAPSHOT-javadoc.jar.asc
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.gradle
build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
44 changes: 44 additions & 0 deletions CODE_OF_CONDUCT.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
= Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of fostering an open
and welcoming community, we pledge to respect all people who contribute through reporting
issues, posting feature requests, updating documentation, submitting pull requests or
patches, and other activities.

We are committed to making participation in this project a harassment-free experience for
everyone, regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance, body size, race, ethnicity, age,
religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses,
without explicit permission
* Other unethical or unprofessional conduct
Project maintainers have the right and responsibility to remove, edit, or reject comments,
commits, code, wiki edits, issues, and other contributions that are not aligned to this
Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
that they deem inappropriate, threatening, offensive, or harmful.

By adopting this Code of Conduct, project maintainers commit themselves to fairly and
consistently applying these principles to every aspect of managing this project. Project
maintainers who do not follow or enforce the Code of Conduct may be permanently removed
from the project team.

This Code of Conduct applies both within project spaces and in public spaces when an
individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
contacting a project maintainer at spring-code-of-conduct@pivotal.io . All complaints will
be reviewed and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. Maintainers are obligated to maintain confidentiality
with regard to the reporter of an incident.

This Code of Conduct is adapted from the
https://contributor-covenant.org[Contributor Covenant], version 1.3.0, available at
https://contributor-covenant.org/version/1/3/0/[contributor-covenant.org/version/1/3/0/]
75 changes: 75 additions & 0 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
= Contributing

This project is released under the Apache 2.0 license.
If you would like to contribute something, or simply want to hack on the code this document should help you get started.



== Code of Conduct
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct].
By participating, you are expected to uphold this code.
Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.



== Using GitHub issues
We use GitHub issues to track bugs and enhancements.
If you are reporting a bug, please help to speed up problem diagnosis by providing as much information as possible.
Ideally, that would include a small sample project that reproduces the problem.



== Sign the Contributor License Agreement
Before we accept a non-trivial patch or pull request we will need you to https://cla.pivotal.io/sign/spring[sign the Contributor License Agreement].
Signing the contributor's agreement does not grant anyone commit rights to the main repository, but it does mean that we can accept your contributions, and you will get an author credit if we do.
Active contributors might be asked to join the core team, and given the ability to merge pull requests.



== Code Conventions and Housekeeping
None of these is essential for a pull request, but they will all help.
They can also be added after the original pull request but before a merge.

* Make sure all new `.java` files to have a simple Javadoc class comment with at least an `@author` tag identifying you, and preferably at least a paragraph on what the class is for.
* Add the ASF license header comment to all new `.java` files (copy from existing files in the project)
* Add yourself as an `@author` to the `.java` files that you modify substantially (more than cosmetic changes).
* Add some Javadocs.
* A few unit tests would help a lot as well -- someone has to do it.
* If no-one else is using your branch, please rebase it against the current main (or other target branch in the main project).
* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit message (where `XXXX` is the issue number).



== Working with the code
If you don't have an IDE preference we would recommend that you use https://spring.io/tools/sts[Spring Tools Suite] or https://eclipse.org[Eclipse] when working with the code.
We use Buildship for Gradle support.
Other IDEs and tools with Gradle support should also work without issue.



=== Building from source
To build the source you will need to install JDK 17.
The project is built with Gradle. Using the wrapper that is included in the project's source is strongly recommended.

The project can be built from the root directory using the standard Gradle command:

[indent=0]
----
$ ./gradlew build
----



==== Integration tests
Docker is required for the integration tests that run as part of the default build.
If you don't have Docker installed, those tests will be automatically skipped.



=== Importing into Eclipse
You can import the resource's code into any Eclipse based distribution with Buildship, the Eclipse Gradle tooling, installed.



=== Importing into other IDEs
Gradle is well supported by most Java IDEs. Refer to your vendor documentation.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM gradle:8.5.0-jdk21-alpine as build
COPY src /app/src/
COPY config /app/config/
COPY build.gradle settings.gradle gradle.properties /app/
RUN cd /app && gradle -Dorg.gradle.welcome=never --no-daemon bootJar

FROM ghcr.io/bell-sw/liberica-openjdk-debian:21.0.2-14
COPY --from=build /app/build/libs/artifactory-deploy-action.jar /opt/action/artifactory-deploy.jar
ENTRYPOINT ["java", "-jar", "/opt/action/artifactory-deploy.jar"]
Loading

0 comments on commit dcac477

Please sign in to comment.