Skip to content

Octolog example workflow #138

Octolog example workflow

Octolog example workflow #138

Workflow file for this run

# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
name: Octolog example workflow
jobs:
test:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: local::.
- name: Test octolog
id: step1
run: |
library(octolog)
library(magrittr)
options(keep.source = TRUE)
enable_github_colors()
source(".github/workflows/R/conditions.R")
octo_inform("Setting envvars for the next step")
octo_set_envvar(c("A multiline", "string"), "MULTI_LINE")
octo_set_envvar("A multiline\nstring", "MULTI_LINE2")
octo_echo_on()
octo_inform("Masking some secret stuff!")
Sys.setenv("SECRET_NUMBER" = "007")
octo_mask_envvar("SECRET_NUMBER")
octo_warn("`octo_mask_envvar` will only take effect in the NEXT step!")
print(Sys.getenv("SECRET_NUMBER"))
octo_mask_value("secret_gh_token")
octo_warn("`octo_mask_value` will take effect immediately!")
print("I accidentally logged my: secret_gh_token")
octo_echo_off()
str <- encode_string(readLines("README.md"), join = TRUE)
octo_set_output(str, "desc")
t <- octo_stop_commands()
octo_inform("This will not be parsed")
octo_start_commands(t)
octo_inform("Now all commands are parsed again!")
octo_warn("The added dir will only be on the path in the next step.")
octo_add_path("bin_dir/", check = FALSE)
system("echo $PATH")
shell: Rscript {0}
- name: Next step
run: |
library(octolog)
octo_warn("The added dir is now available!")
system("echo $PATH")
print("I accidentally logged my: secret_gh_token")
print("secret_gh_token")
octo_inform("Now in the next step the envvar mask has taken effect:")
print(Sys.getenv("SECRET_NUMBER"))
system("echo $SECRET_NUMBER")
system("echo 'Oh no:secret_gh_token'")
octo_inform("The envvar set in the last step can be used now:")
print(Sys.getenv("MULTI_LINE"))
print(Sys.getenv("MULTI_LINE2"))
octo_inform("We can use outputs from previous steps in other steps using the step id.")
octo_inform("Multiline strings will be automatically converted from their escaped form.")
cat('${{steps.step1.outputs.desc}}')
shell: Rscript {0}