Expand description
Github Action Cache Services support.
Notes
This service is mainly provided by github actions.
Refer to Caching dependencies to speed up workflows for more informatio.
To make this service work as expected, please make sure the following environment has been setup correctly:
ACTIONS_CACHE_URL
ACTIONS_RUNTIME_TOKEN
They can be exposed by following action:
- name: Configure Cache Env
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
To make delete
work as expected, GITHUB_TOKEN
should also be set via:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Limitations
Unlike other services, ghac doesn’t support create empty files.
We provide a enable_create_simulation()
to support this operation but may result unexpected side effects.
Also, ghac
is a cache service which means the data store inside could
be automatically evicted at any time.
Configuration
root
: Set the work dir for backend.
Refer to Builder
’s public API docs for more information.
Environment
OPENDAL_GHAC_ROOT
Example
Via Environment
Set environment correctly:
export OPENDAL_GHAC_ROOT=/path/to/dir/
use std::sync::Arc;
use anyhow::Result;
use opendal::Object;
use opendal::Operator;
use opendal::Scheme;
#[tokio::main]
async fn main() -> Result<()> {
let op: Operator = Operator::from_env(Scheme::Ghac)?;
// Create an object handle to start operation on object.
let _: Object = op.object("test_file");
Ok(())
}
Via Builder
use std::sync::Arc;
use anyhow::Result;
use opendal::services::ghac;
use opendal::Object;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// Create ghac backend builder.
let mut builder = ghac::Builder::default();
// Set the root for ghac, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
builder.root("/path/to/dir");
let op: Operator = Operator::new(builder.build()?);
// Create an object handle to start operation on object.
let _: Object = op.object("test_file");
Ok(())
}
Structs
Builder for github action cache services.