steps.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package actions
  2. import (
  3. "fmt"
  4. )
  5. func getCheckoutCodeStep() GithubActionYAMLStep {
  6. return GithubActionYAMLStep{
  7. Name: "Checkout code",
  8. Uses: "actions/checkout@v2.3.4",
  9. }
  10. }
  11. const download string = `name=$(curl -s https://api.github.com/repos/porter-dev/porter/releases/latest | grep "browser_download_url.*/porter_.*_Linux_x86_64\.zip" | cut -d ":" -f 2,3 | tr -d \")
  12. name=$(basename $name)
  13. curl -L https://github.com/porter-dev/porter/releases/latest/download/$name --output $name
  14. unzip -a $name
  15. rm $name
  16. chmod +x ./porter
  17. sudo mv ./porter /usr/local/bin/porter
  18. `
  19. func getDownloadPorterStep() GithubActionYAMLStep {
  20. return GithubActionYAMLStep{
  21. Name: "Download Porter",
  22. ID: "download_porter",
  23. Run: download,
  24. }
  25. }
  26. const configure string = `porter update --app %s`
  27. func getConfigurePorterStep(serverURL, porterTokenSecretName string, projectID uint, clusterID uint, appName string) GithubActionYAMLStep {
  28. return GithubActionYAMLStep{
  29. Name: "Update Porter App",
  30. ID: "update_porter",
  31. Run: fmt.Sprintf(configure, appName),
  32. Timeout: 20,
  33. Env: map[string]string{
  34. "PORTER_TOKEN": fmt.Sprintf("${{ secrets.%s }}", porterTokenSecretName),
  35. "PORTER_HOST": serverURL,
  36. "PORTER_PROJECT": fmt.Sprintf("%d", projectID),
  37. "PORTER_CLUSTER": fmt.Sprintf("%d", clusterID),
  38. },
  39. }
  40. }