diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml new file mode 100644 index 0000000..e1ae452 --- /dev/null +++ b/.gitea/workflows/docker-image.yml @@ -0,0 +1,39 @@ +name: Publish Docker Image + +on: + push: + branches: ["master"] + paths-ignore: + - .gitignore + - README.md + - LICENSE + +jobs: + docker: + strategy: + matrix: + arch: ["ubuntu-latest"] + runs-on: ${{ matrix.arch }} + + # Steps to run + steps: + # Checkout the repo + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Login to Docker Hub + - name: Login to Repo + uses: docker/login-action@v3 + with: + username: ${{ secrets.REPO_USERNAME }} + password: ${{ secrets.REPO_TOKEN }} + + # Build the Docker image + - name: Build Docker Image + uses: docker/build-push-action@v5 + with: + push: true + context: . + tags: fascinated/paste-backend:latest \ No newline at end of file diff --git a/src/main/java/cc/fascinated/backend/model/Paste.java b/src/main/java/cc/fascinated/backend/model/Paste.java index 9bf2699..1a7a7d8 100644 --- a/src/main/java/cc/fascinated/backend/model/Paste.java +++ b/src/main/java/cc/fascinated/backend/model/Paste.java @@ -14,6 +14,11 @@ public class Paste { @Id @NonNull private final String id; + /** + * The time the paste was created. + */ + private final long created; + /** * The content of the paste. */ diff --git a/src/main/java/cc/fascinated/backend/service/PasteService.java b/src/main/java/cc/fascinated/backend/service/PasteService.java index 9eae771..da03cb1 100644 --- a/src/main/java/cc/fascinated/backend/service/PasteService.java +++ b/src/main/java/cc/fascinated/backend/service/PasteService.java @@ -36,7 +36,11 @@ public class PasteService { * @return The id of the paste. */ public String createPaste(String content) { - return pasteRepository.save(new Paste(RandomStringUtils.randomAlphabetic(idLength), content)).getId(); + return pasteRepository.save(new Paste( + RandomStringUtils.randomAlphabetic(idLength), + System.currentTimeMillis(), + content + )).getId(); } /**