mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
ci: udpated workflow
This commit is contained in:
52
.github/workflows/docker-crawlab.yml
vendored
52
.github/workflows/docker-crawlab.yml
vendored
@@ -287,55 +287,3 @@ jobs:
|
||||
run: |
|
||||
docker tag ${{ env.IMAGE_NAME_CRAWLAB }}:${{ needs.setup.outputs.version }} ${{ (matrix.registry == 'dockerhub' && env.IMAGE_NAME_CRAWLAB_DOCKERHUB) || (matrix.registry == 'tencent' && env.IMAGE_NAME_CRAWLAB_TENCENT) }}:${{ needs.setup.outputs.version }}
|
||||
docker push ${{ (matrix.registry == 'dockerhub' && env.IMAGE_NAME_CRAWLAB_DOCKERHUB) || (matrix.registry == 'tencent' && env.IMAGE_NAME_CRAWLAB_TENCENT) }}:${{ needs.setup.outputs.version }}
|
||||
|
||||
cleanup:
|
||||
needs: [setup, build_backend, build_frontend, build_crawlab, push_images]
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
image: [
|
||||
{ name: 'crawlab' },
|
||||
{ name: 'crawlab-backend' },
|
||||
{ name: 'crawlab-frontend' }
|
||||
]
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
id: setup_node
|
||||
if: |
|
||||
(matrix.image.name == 'crawlab' && needs.build_crawlab.result == 'success') ||
|
||||
(matrix.image.name == 'crawlab-backend' && needs.build_backend.result == 'success') ||
|
||||
(matrix.image.name == 'crawlab-frontend' && needs.build_frontend.result == 'success')
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: List Docker image versions
|
||||
if: ${{ steps.setup_node.outcome == 'success' }}
|
||||
id: list_versions
|
||||
run: |
|
||||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
https://api.github.com/orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image.name }}/versions > versions.json
|
||||
|
||||
cat versions.json
|
||||
|
||||
node -e "
|
||||
const fs = require('fs');
|
||||
const data = JSON.parse(fs.readFileSync('versions.json', 'utf8'));
|
||||
const tag = '${{ needs.setup.outputs.version }}';
|
||||
const versionIds = data
|
||||
.filter(version => version.metadata.container.tags.some(t => t.includes(tag)))
|
||||
.map(version => version.id);
|
||||
fs.writeFileSync('version_ids.txt', versionIds.join('\n'));
|
||||
"
|
||||
|
||||
echo "version_ids=$(cat version_ids.txt | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Delete Docker image versions
|
||||
uses: actions/delete-package-versions@v5
|
||||
with:
|
||||
package-name: ${{ matrix.image.name }}
|
||||
package-type: 'container'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
package-version-ids: ${{ steps.list_versions.outputs.version_ids }}
|
||||
Reference in New Issue
Block a user