edits to custom transformers lab

Note: line 200 might include an error.
This commit is contained in:
Jennifer Kerns
2022-11-07 10:31:42 -08:00
committed by GitHub
parent 6f3c122e01
commit ff002aa1dd
+5 -5
View File
@@ -1,6 +1,6 @@
# Using custom transformers to customize GitHub Actions Importer's behavior # Using custom transformers to customize GitHub Actions Importer's behavior
In this lab you will build upon the `dry-run` command to override GitHub Actions Importer's default behavior and customize the converted workflow using "custom transformers". Custom transformers can be used to: In this lab you will build upon the `dry-run` command to override GitHub Actions Importer's default behavior and customize the converted workflow using "custom transformers." Custom transformers can be used to:
1. Convert items that are not automatically converted. 1. Convert items that are not automatically converted.
2. Convert items that were automatically converted using different actions. 2. Convert items that were automatically converted using different actions.
@@ -81,7 +81,7 @@ The converted workflow above contains an `codedeploy` step that was not automati
- __codedeploy__ - __codedeploy__
2. What is the desired Actions syntax to use instead? 2. What is the desired Actions syntax to use instead?
- After some research, you have determined that we can login to AWS with the `aws-actions/configure-aws-credentials@v1` action, and deploy the app to AWS using a run step to replace the functionality of `codedeploy`: - After some research, you have determined that you can log in to AWS with the `aws-actions/configure-aws-credentials@v1` action, and deploy the app to AWS using a run step to replace the functionality of `codedeploy`:
```yaml ```yaml
- uses: aws-actions/configure-aws-credentials@v1 - uses: aws-actions/configure-aws-credentials@v1
@@ -121,7 +121,7 @@ transform "codedeploy" do |_item|
end end
``` ```
This method can use any valid ruby syntax and should return a `Hash`, or an array of `Hashes` that represent the YAML that should be generated for a given step. GitHub Actions Importer will use this method to convert a step with the provided identifier and will use the `item` parameter for the original values configured in Travis CI. This method can use any valid Ruby syntax and should return a `Hash`, or an array of `Hashes` that represent the YAML that should be generated for a given step. GitHub Actions Importer will use this method to convert a step with the provided identifier and will use the `item` parameter for the original values configured in Travis CI.
Now you can perform another `dry-run` command and use the `--custom-transformers` CLI option to provide this custom transformer. Run the following command within your codespace terminal: Now you can perform another `dry-run` command and use the `--custom-transformers` CLI option to provide this custom transformer. Run the following command within your codespace terminal:
@@ -153,7 +153,7 @@ The converted workflow that is generated by the above command will now use the c
+ aws deploy create-deployment --application-name MyApp --deployment-group-name MyDeploymentGroup --github-location repository=$GITHUB_REPOSITORY,commitId=$commit_hash --ignore-application-stop-failures + aws deploy create-deployment --application-name MyApp --deployment-group-name MyDeploymentGroup --github-location repository=$GITHUB_REPOSITORY,commitId=$commit_hash --ignore-application-stop-failures
``` ```
_Note_: We hard coded certain values such as the `application-name`, but we can apply these properties programmatically as well by using the item passed into the transform method. If you were unsure what the data structure of `item` was, you could use the following code in the custom transformer to print `item` to the console: _Note_: Certain values such as the `application-name` are hard-coded, but you can apply these properties programmatically as well by using the item passed into the transform method. If you were unsure what the data structure of `item` was, you could use the following code in the custom transformer to print `item` to the console:
```ruby ```ruby
transform "codecov_codecov_upload" do |item| transform "codecov_codecov_upload" do |item|
@@ -237,7 +237,7 @@ runner "linux", ["new-runner", "self-hosted"]
</details> </details>
That's it! Congratulations, you have overridden GitHub Actions Importer's default behavior by customizing the conversion of: That's it. Congratulations, you have overridden GitHub Actions Importer's default behavior by customizing the conversion of:
- Unknown steps - Unknown steps
- Environment variables - Environment variables