Skip to content

Commit

Permalink
Merge pull request #20 from primayoriko/fix/refactor
Browse files Browse the repository at this point in the history
[Pipeline] add test pipeline
  • Loading branch information
primayoriko authored Oct 10, 2021
2 parents c057b0b + 08314da commit 1d895c0
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 65 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when a release is created
#
# To configure this workflow:
#
# 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc.
#
# 2. Set up secrets in your workspace: GKE_PROJECT with the name of the project and GKE_SA_KEY with the Base64 encoded JSON service account key (https://github.com/GoogleCloudPlatform/github-actions/tree/docs/service-account-key/setup-gcloud#inputs).
#
# 3. Change the values for the GKE_ZONE, GKE_CLUSTER, IMAGE, and DEPLOYMENT_NAME environment variables (below).
#
# For more support on how to run the workflow, please visit https://github.com/google-github-actions/setup-gcloud/tree/master/example-workflows/gke

name: Build and Deploy to GKE

on:
push:
branches:
- main
pull_request:
branches:
- main
# Also trigger on page_build, as well as release created events
page_build:
release:
types: # This configuration does not affect the page_build event above
- created

env:
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
MAIL_HOST: ${{ secrets.MAIL_HOST }}
MAIL_PORT: ${{ secrets.MAIL_PORT }}
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }}
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
FIREBASE_CREDENTIALS: ${{ secrets.FIREBASE_CREDENTIALS }}
FIREBASE_BUCKET_NAME: ${{ secrets.FIREBASE_BUCKET_NAME }}
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: resto-future-cluster
GKE_ZONE: asia-southeast1-a
DEPLOYMENT_NAME: restoapp
IMAGE: future/restoapp

jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Create Package and Test
run: |-
mvn clean package
Original file line number Diff line number Diff line change
Expand Up @@ -50,44 +50,4 @@ public String saveImage(@NotBlank String filename, @NotBlank String mimeType, @N
return String.format(imageUrlFormat, filename);
}

// public byte[] getImageBytes(@NotBlank String filename) throws Exception {
// String path = new File(".").getCanonicalPath() + IMAGE_MENU_DIRECTORY + "/" + filename;
// return FileUtils.readFileToByteArray(new File(path));
//// System.out.println(path);
//// InputStream in = context.getResourceAsStream(path);
//// InputStream in = getClass().getClassLoader().getResourceAsStream(path);
//// System.out.println(context.getContextPath());
//// System.out.println(context.getResource(".").getFile());
//// System.out.println(context.getResource(".").getPath());
//// System.out.println(context.getRealPath("."));
//// System.out.println("sadasd");
//// System.out.println(context.getClass().getResource(".").getFile());
//// System.out.println(context.getClass().getResource(".").getPath());
//// System.out.println("1234sadasd");
//// System.out.println(context.getClassLoader().getResource(".").getFile());
//// System.out.println(context.getClassLoader().getResource(".").getPath());
//// ApplicationContext ctx = new FileSystemXmlApplicationContext
// }

// public String getImageBase64(@NotBlank String filename) throws Exception {
// byte[] fileContent = getImageBytes(filename);
// return Base64.getEncoder().encodeToString(fileContent);
// }

// public String addImage(@NotBlank String filename, @NotBlank String base64Content) throws Exception {
// String path = new File(".").getCanonicalPath() + IMAGE_MENU_DIRECTORY + "/" + filename;
// byte[] decodedBytes = Base64.getDecoder().decode(base64Content);
//
// FileUtils.writeByteArrayToFile(new File(path), decodedBytes);
//
// return path;
// }

// public boolean deleteImage(@NotBlank String filename) throws Exception {
// String path = new File(".").getCanonicalPath() + IMAGE_MENU_DIRECTORY + "/" + filename;
// File imageFile = new File(path);
//
// return imageFile.delete();
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,9 @@ public class MailServiceImpl implements MailService {
@Autowired
private SpringTemplateEngine templateEngine;

// @Autowired
// private SimpleMailMessage template;

@Value("classpath:/mail-logo.png")
private Resource resourceFile;

// public void sendSimpleMessage(String to, String subject, String text) {
// try {
// SimpleMailMessage message = new SimpleMailMessage();
// message.setFrom(NOREPLY_ADDRESS);
// message.setTo(to);
// message.setSubject(subject);
// message.setText(text);
//
// emailSender.send(message);
// } catch (MailException exception) {
// exception.printStackTrace();
// }
// }
//
// public void sendSimpleMessageWithTemplate(String to,
// String subject,
// String ...templateModel) {
// String text = String.format(template.getText(), templateModel);
// sendSimpleMessage(to, subject, text);
// }

@Override
public void sendMessageWithTemplate(
String to, String subject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void run()
);
} catch (Exception e) {
System.out.println(e.getMessage());
// throw e;
}
}
}
Expand Down

0 comments on commit 1d895c0

Please sign in to comment.