forked from Mirror/attic-action
Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
6544c41112 | |||
80432ea2ff | |||
31f177f66d | |||
81793b07ae | |||
5121b742ce | |||
fe7e4e104a | |||
54b0d06fc7 | |||
|
5619ef4781 | ||
|
37f74ba5fa | ||
|
6cfb1137df | ||
|
f75ac4b827 |
8 changed files with 54 additions and 83 deletions
.forgejo/workflows
.github
dist
src
25
.forgejo/workflows/test.yml
Normal file
25
.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
name: "Test"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["main"]
|
||||||
|
workflow_call:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-cache:
|
||||||
|
runs-on: nix-flakes
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Attic Cache
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
endpoint: ${{ vars.ATTIC_ENDPOINT }}
|
||||||
|
cache: ${{ vars.ATTIC_CACHE }}
|
||||||
|
token: ${{ secrets.ATTIC_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Nix Package
|
||||||
|
run: nix-build test.nix
|
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
|
@ -1,7 +0,0 @@
|
||||||
version: 2
|
|
||||||
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
31
.github/workflows/release.yml
vendored
31
.github/workflows/release.yml
vendored
|
@ -1,31 +0,0 @@
|
||||||
name: Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published, edited]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event.release.tag_name }}
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
cache: pnpm
|
|
||||||
cache-dependency-path: pnpm-lock.yaml
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm install && pnpm build
|
|
||||||
|
|
||||||
- uses: JasonEtco/build-and-tag-action@v2
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
|
41
.github/workflows/test.yml
vendored
41
.github/workflows/test.yml
vendored
|
@ -1,41 +0,0 @@
|
||||||
name: "Test"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
workflow_call:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-cache:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v2
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
cache: pnpm
|
|
||||||
cache-dependency-path: pnpm-lock.yaml
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: pnpm install && pnpm build
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: DeterminateSystems/nix-installer-action@v7
|
|
||||||
|
|
||||||
- name: Setup Attic Cache
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
endpoint: ${{ secrets.ATTIC_ENDPOINT }}
|
|
||||||
cache: ${{ secrets.ATTIC_CACHE }}
|
|
||||||
token: ${{ secrets.ATTIC_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build Nix Package
|
|
||||||
run: nix-build test.nix
|
|
8
dist/index.js
vendored
Normal file
8
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10
src/index.ts
10
src/index.ts
|
@ -1,12 +1,16 @@
|
||||||
import { install } from "./stages/install";
|
import { install, isInstalled } from "./stages/install";
|
||||||
import { configure } from "./stages/configure";
|
import { configure } from "./stages/configure";
|
||||||
import { push } from "./stages/push";
|
import { push } from "./stages/push";
|
||||||
import { getState, saveState } from "@actions/core";
|
import { getState, saveState, info } from "@actions/core";
|
||||||
|
|
||||||
const isPost = !!getState("isPost");
|
const isPost = !!getState("isPost");
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
await install();
|
if (await isInstalled()) {
|
||||||
|
info("Skipping attic installation because it is already installed");
|
||||||
|
} else {
|
||||||
|
await install();
|
||||||
|
}
|
||||||
await configure();
|
await configure();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,3 +33,9 @@ export const install = async () => {
|
||||||
|
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isInstalled = async () => {
|
||||||
|
let return_code = await exec("attic", ["-V"]);
|
||||||
|
core.info(`Attic command returned code ${return_code}`);
|
||||||
|
return return_code === 0;
|
||||||
|
};
|
||||||
|
|
|
@ -6,5 +6,12 @@ export const saveStorePaths = async () => {
|
||||||
await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]);
|
await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]);
|
||||||
};
|
};
|
||||||
export const getStorePaths = async () => {
|
export const getStorePaths = async () => {
|
||||||
return (JSON.parse(await readFile("/tmp/store-paths", "utf8")) as { path: string }[]).map((path) => path.path);
|
const rawStorePaths = JSON.parse(await readFile("/tmp/store-paths", "utf8")) as { path: string }[];
|
||||||
|
|
||||||
|
// compatibility with Nix 2.18
|
||||||
|
if (Array.isArray(rawStorePaths)) {
|
||||||
|
return rawStorePaths.map((path) => path.path);
|
||||||
|
};
|
||||||
|
|
||||||
|
return Object.keys(rawStorePaths);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue