This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from wireapp/github-actions
GitHub actions
- Loading branch information
Showing
38 changed files
with
353 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.gitignore | ||
.travis.yml | ||
Dockerfile | ||
don.iml | ||
.idea/ | ||
build/ | ||
target/ | ||
README.md | ||
script.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: CI/CD | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set envs | ||
# use latest tag as release version | ||
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_SHA} | ||
|
||
- name: Build docker image, publish image as latest if the branch is master | ||
uses: docker/build-push-action@v1 | ||
with: | ||
repository: wire-bot/don-bot | ||
# login to repo | ||
registry: eu.gcr.io | ||
# see https://github.com/marketplace/actions/docker-build-push#google-container-registry-gcr | ||
username: _json_key | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
# pass release_version | ||
build_args: release_version=${{ env.RELEASE_VERSION }} | ||
# build as latest | ||
tags: latest | ||
# add labels based on the build - see https://github.com/opencontainers/image-spec/blob/master/annotations.md | ||
add_git_labels: true | ||
# push only if this is master branch | ||
push: ${{ startsWith(github.ref, 'refs/heads/master') }} | ||
|
||
# Send webhook to Wire using Slack Bot | ||
- name: Webhook to Wire | ||
uses: 8398a7/action-slack@v2 | ||
with: | ||
status: ${{ job.status }} | ||
author_name: Don Bot CI pipeline | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_CI }} | ||
# Send message only if previous step failed | ||
if: failure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Release Pipeline | ||
|
||
on: | ||
release: | ||
types: published | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set envs | ||
# use latest tag as release version | ||
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10} | ||
|
||
- name: Build and publish docker image with git tag | ||
uses: docker/build-push-action@v1 | ||
with: | ||
repository: wire-bot/don-bot | ||
# login to repo | ||
registry: eu.gcr.io | ||
# see https://github.com/marketplace/actions/docker-build-push#google-container-registry-gcr | ||
username: _json_key | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
# pass release_version | ||
build_args: release_version=${{ env.RELEASE_VERSION }} | ||
# tag the image with latest git tag | ||
tag_with_ref: true | ||
# add labels based on the build - see https://github.com/opencontainers/image-spec/blob/master/annotations.md | ||
add_git_labels: true | ||
# push only if this is tagged release | ||
push: ${{ startsWith(github.ref, 'refs/tags/') }} | ||
|
||
# Send webhook to Wire using Slack Bot | ||
- name: Webhook to Wire | ||
uses: 8398a7/action-slack@v2 | ||
with: | ||
status: ${{ job.status }} | ||
author_name: Don Bot Release Pipeline | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_RELEASE }} | ||
# Notify every release | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
FROM docker.io/maven AS build-env | ||
|
||
WORKDIR /app | ||
|
||
COPY pom.xml ./ | ||
|
||
RUN mvn verify --fail-never -U | ||
|
||
COPY . ./ | ||
|
||
RUN mvn -Dmaven.test.skip=true package | ||
|
||
FROM dejankovacevic/bots.runtime:2.10.3 | ||
|
||
COPY target/don.jar /opt/don/don.jar | ||
COPY don.yaml /etc/don/don.yaml | ||
COPY --from=build-env /app/target/don.jar /opt/don/ | ||
|
||
COPY don.yaml /etc/don/don.yaml | ||
|
||
# create version file | ||
ARG release_version=development | ||
ENV RELEASE_FILE_PATH=/opt/don/release.txt | ||
RUN echo $release_version > $RELEASE_FILE_PATH | ||
|
||
WORKDIR /opt/don | ||
|
||
EXPOSE 8080 8081 8082 | ||
|
||
ENTRYPOINT ["java", "-jar", "don.jar", "server", "/etc/don/don.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env bash | ||
mvn package -DskipTests=true -Dmaven.javadoc.skip=true | ||
docker build -t $DOCKER_USERNAME/don-bot:latest . | ||
docker build -t $DOCKER_USERNAME/don-bot:1.2.0 . | ||
docker push $DOCKER_USERNAME/don-bot | ||
kubectl delete pod -l name=don -n prod | ||
kubectl get pods -l name=don -n prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,22 @@ | ||
server: | ||
applicationConnectors: | ||
- type: http | ||
port: 8080 | ||
|
||
rootPath: /don/* | ||
requestLog: | ||
appenders: [] | ||
|
||
auth: ${WIRE_SERVICE_TOKEN} | ||
appenders: | ||
- type: console | ||
filterFactories: | ||
- type: status-filter-factory | ||
|
||
logging: | ||
level: INFO | ||
loggers: | ||
"com.wire.bots.sdk.tools.logger": INFO | ||
"com.wire.bots.logger": ${LOG_LEVEL:-INFO} | ||
|
||
swagger: | ||
resourcePackage: com.wire.bots.sdk.server.resources | ||
uriPrefix: /don | ||
schemes: | ||
- http | ||
- https | ||
auth: ${SERVICE_TOKEN:-} | ||
apiHost: ${WIRE_API_HOST:-https://prod-nginz-https.wire.com} | ||
|
||
postgres: | ||
host: localhost | ||
port: 5432 | ||
driver: postgresql | ||
user: ${POSTRES_USER} | ||
password: ${POSTRES_PASSWORD} | ||
database: | ||
driverClass: ${DB_DRIVER:-org.postgresql.Driver} | ||
url: ${DB_URL:-jdbc:postgresql://localhost/don} | ||
user: ${DB_USER:-} | ||
password: ${DB_PASSWORD:-} | ||
|
||
db: | ||
host: localhost | ||
port: 6379 #redis port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.wire.bots.don.DAO; | ||
|
||
import com.wire.bots.don.DAO.model.Service; | ||
import org.skife.jdbi.v2.StatementContext; | ||
import org.skife.jdbi.v2.sqlobject.Bind; | ||
import org.skife.jdbi.v2.sqlobject.SqlQuery; | ||
import org.skife.jdbi.v2.sqlobject.SqlUpdate; | ||
import org.skife.jdbi.v2.sqlobject.customizers.Define; | ||
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; | ||
import org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator; | ||
import org.skife.jdbi.v2.tweak.ResultSetMapper; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
@UseStringTemplate3StatementLocator | ||
public interface ServiceDAO { | ||
@SqlUpdate("INSERT INTO Service (Name) VALUES(:name)") | ||
int insertService(@Bind("name") String name); | ||
|
||
@SqlQuery("SELECT * FROM Service WHERE Id = :serviceId") | ||
@RegisterMapper(_Mapper.class) | ||
Service getService(@Bind("serviceId") int serviceId); | ||
|
||
@SqlUpdate("UPDATE Service SET <column> = :value WHERE id = :serviceId") | ||
int updateService(@Bind("serviceId") int serviceId, @Define("column") String column, @Bind("value") String value); | ||
|
||
class _Mapper implements ResultSetMapper<Service> { | ||
@Override | ||
public Service map(int i, ResultSet rs, StatementContext statementContext) throws SQLException { | ||
Service service = new Service(); | ||
service.id = rs.getInt("id"); | ||
service.name = rs.getString("name"); | ||
service.description = rs.getString("description"); | ||
service.url = rs.getString("url"); | ||
service.profile = rs.getString("profile"); | ||
service.serviceId = rs.getString("serviceId"); | ||
service.field = rs.getString("field"); | ||
return service; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.wire.bots.don.DAO; | ||
|
||
|
||
import com.wire.bots.don.DAO.model.User; | ||
import org.skife.jdbi.v2.StatementContext; | ||
import org.skife.jdbi.v2.sqlobject.Bind; | ||
import org.skife.jdbi.v2.sqlobject.SqlQuery; | ||
import org.skife.jdbi.v2.sqlobject.SqlUpdate; | ||
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; | ||
import org.skife.jdbi.v2.tweak.ResultSetMapper; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.UUID; | ||
|
||
public interface UserDAO { | ||
@SqlUpdate("INSERT INTO Developer (UserId, Name) VALUES(:userId, :name)") | ||
int insertUser(@Bind("userId") UUID userId, @Bind("name") String name); | ||
|
||
@SqlQuery("SELECT * FROM Developer WHERE UserId = :userId") | ||
@RegisterMapper(_Mapper.class) | ||
User getUser(@Bind("userId") UUID userId); | ||
|
||
@SqlUpdate("UPDATE Developer SET Email = :email, Provider = :provider WHERE UserId = :userId") | ||
int updateUser(@Bind("userId") UUID userId, @Bind("email") String email, @Bind("provider") String provider); | ||
|
||
@SqlUpdate("UPDATE Developer SET cookie = :cookie WHERE UserId = :userId") | ||
int updateCookie(@Bind("userId") UUID userId, @Bind("cookie") String cookie); | ||
|
||
@SqlUpdate("UPDATE Developer SET cookie = null WHERE UserId = :userId") | ||
int deleteCookie(@Bind("userId") UUID userId); | ||
|
||
class _Mapper implements ResultSetMapper<User> { | ||
@Override | ||
public User map(int i, ResultSet rs, StatementContext statementContext) throws SQLException { | ||
User user = new User(); | ||
user.id = (UUID) rs.getObject("UserId"); | ||
user.name = rs.getString("name"); | ||
user.email = rs.getString("email"); | ||
user.provider = rs.getString("provider"); | ||
user.cookie = rs.getString("cookie"); | ||
|
||
return user; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...in/java/com/wire/bots/don/db/Service.java → .../com/wire/bots/don/DAO/model/Service.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.wire.bots.don.db; | ||
package com.wire.bots.don.DAO.model; | ||
|
||
public class Service { | ||
public int id; | ||
|
7 changes: 4 additions & 3 deletions
7
src/main/java/com/wire/bots/don/db/User.java → ...ava/com/wire/bots/don/DAO/model/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.wire.bots.don.db; | ||
package com.wire.bots.don.DAO.model; | ||
|
||
import java.util.UUID; | ||
|
||
public class User { | ||
public String id; | ||
public UUID id; | ||
public String name; | ||
public String email; | ||
// public String password; | ||
public String provider; | ||
public String cookie; | ||
} |
Oops, something went wrong.