Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shino committed Feb 21, 2025
1 parent 0335f8d commit 74fe67e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/archive-raw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,14 @@ jobs:
- name: Check out code
uses: actions/checkout@v4
with:
ref: main

- name: Check out fetch data repository
run: |
oras pull ghcr.io/${{ github.repository }}:vuls-data-raw-${{ matrix.target }}
tar -xf vuls-data-raw-${{ matrix.target }}.tar.zst
- name: Decide to archive
id: archive_check
run: |
oras pull ghcr.io/${{ github.repository }}:vuls-data-raw-${{ matrix.target }}
SIZE=$(ls -s --block-size=1 vuls-data-raw-${{ matrix.target }}.tar.zst | awk '{print $1;}')
echo "repository size [KB]:" $(( ${SIZE} / 1024 ))
echo "repository size [MB]:" $(( ${SIZE} / 1024 / 1024 ))
Expand All @@ -177,14 +173,26 @@ jobs:
run: |
ARCHIVE_SUFFIX=$(./scripts/split-git.sh vuls-data-raw-${{ matrix.target }})
echo "archive_suffix=${ARCHIVE_SUFFIX}" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Login to GitHub Packages Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push archive dotgit
if: steps.archive_check.outputs.do_archive == 'true'
run: |
ARCHIVE_SUFFIX=$(./scripts/split-git.sh vuls-data-raw-${{ matrix.target }})
oras push ghcr.io/vulsio/vuls-data-db:vuls-data-raw-${{ matrix.target }}-${{ steps.split_archive.outputs.archive_suffix }} vuls-data-raw-${{ matrix.target }}-${{ steps.split_archive.outputs.archive_suffix }}.tar.zst:application/vnd.vulsio.vuls-data-db.dotgit.layer.v1.tar+zstd
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push latest dotgit
if: steps.archive_check.outputs.do_archive == 'true'
run: |
oras push ghcr.io/vulsio/vuls-data-db:vuls-data-raw-${{ matrix.target }} vuls-data-raw-${{ matrix.target }}.tar.zst:application/vnd.vulsio.vuls-data-db.dotgit.layer.v1.tar+zstd
2 changes: 2 additions & 0 deletions scripts/split-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ ARCHIVE_MAX=$(
)

ARCHIVE_SUFFIX=archive-$(( ${ARCHIVE_MAX} + 1 ))
echo "ARCHIVE_SUFFIX=${ARCHIVE_SUFFIX}" 1>&2

tar -xf ${TARGET}.tar.zst
mv ${TARGET}.tar.zst ${TARGET}-${ARCHIVE_SUFFIX}.tar.zst

mv ${TARGET} ${TARGET}-${ARCHIVE_SUFFIX}
echo "Create the latest repository..." 1>&2
git clone --depth 1 --no-single-branch --no-checkout --branch main file://${PWD}/${TARGET}-${ARCHIVE_SUFFIX} ${TARGET}
tar --remove-files -acf ${TARGET}.tar.zst ${TARGET}

Expand Down

0 comments on commit 74fe67e

Please sign in to comment.