about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-07-24 20:53:08 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-07-24 20:53:27 +0200
commitc0b2b15123e500e5af90138646f20024ca746f86 (patch)
tree802deaf00f705e2370c238cfe92935e1100b0706
parentcc0c8b2882c7a0b00bc30e0c22040f7d4ba9f584 (diff)
downloadrust-c0b2b15123e500e5af90138646f20024ca746f86.tar.gz
rust-c0b2b15123e500e5af90138646f20024ca746f86.zip
Fix metrics
-rw-r--r--.github/workflows/metrics.yaml8
-rw-r--r--xtask/src/metrics.rs14
2 files changed, 8 insertions, 14 deletions
diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml
index 4974867f639..ea780e8756e 100644
--- a/.github/workflows/metrics.yaml
+++ b/.github/workflows/metrics.yaml
@@ -18,12 +18,6 @@ jobs:
     - name: Checkout repository
       uses: actions/checkout@v2
 
-    - name: Checkout metrics repository
-      uses: actions/checkout@v2
-      with:
-        repository: "rust-analyzer/metrics"
-        path: "target/metrics"
-
     - name: Install Rust toolchain
       uses: actions-rs/toolchain@v1
       with:
@@ -35,4 +29,4 @@ jobs:
     - name: Collect metrics
       run: cargo xtask metrics
       env:
-        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        METRICS_TOKEN: ${{ secrets.METRICS_TOKEN }}
diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs
index 612bef51f8d..bb3044f4111 100644
--- a/xtask/src/metrics.rs
+++ b/xtask/src/metrics.rs
@@ -17,17 +17,17 @@ pub fn run_metrics() -> Result<()> {
     metrics.measure_build()?;
 
     {
-        let _d = pushd("target/metrics");
+        let _d = pushd("target");
+        let api_token = env::var("METRICS_TOKEN").unwrap();
+        let repo = format!("https://{}@github.com/rust-analyzer/metrics.git", api_token);
+        run!("git clone --depth 1 {}", repo)?;
+        let _d = pushd("metrics");
+
         let mut file = std::fs::OpenOptions::new().append(true).open("metrics.json")?;
         writeln!(file, "{}", metrics.json())?;
         run!("git add .")?;
         run!("git -c user.name=Bot -c user.email=dummy@example.com commit --message 📈")?;
-
-        if let Ok(actor) = env::var("GITHUB_ACTOR") {
-            let token = env::var("GITHUB_TOKEN").unwrap();
-            let repo = format!("https://{}:{}@github.com/rust-analyzer/metrics.git", actor, token);
-            run!("git push {}", repo)?;
-        }
+        run!("git push origin master")?;
     }
     eprintln!("{:#?}\n", metrics);
     eprintln!("{}", metrics.json());