steps.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package actions
  2. import (
  3. "fmt"
  4. )
  5. const updateAppActionName = "porter-dev/porter-update-action"
  6. func getCheckoutCodeStep() GithubActionYAMLStep {
  7. return GithubActionYAMLStep{
  8. Name: "Checkout code",
  9. Uses: "actions/checkout@v2.3.4",
  10. }
  11. }
  12. func getSetTagStep() GithubActionYAMLStep {
  13. return GithubActionYAMLStep{
  14. Name: "Set Github tag",
  15. ID: "vars",
  16. Run: `echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"`,
  17. }
  18. }
  19. func getUpdateAppStep(serverURL, porterTokenSecretName string, projectID uint, clusterID uint, appName string, appNamespace, actionVersion string) GithubActionYAMLStep {
  20. return GithubActionYAMLStep{
  21. Name: "Update Porter App",
  22. Uses: fmt.Sprintf("%s@%s", updateAppActionName, actionVersion),
  23. With: map[string]string{
  24. "app": appName,
  25. "cluster": fmt.Sprintf("%d", clusterID),
  26. "host": serverURL,
  27. "project": fmt.Sprintf("%d", projectID),
  28. "token": fmt.Sprintf("${{ secrets.%s }}", porterTokenSecretName),
  29. "tag": "${{ steps.vars.outputs.sha_short }}",
  30. "namespace": appNamespace,
  31. },
  32. Timeout: 20,
  33. }
  34. }