|
1 | 1 | --- |
| 2 | +# This workflow is designed to clean up old Docker container versions in a GitHub repository. |
2 | 3 | name: Cleanup Old Docker Container Versions |
3 | 4 | run-name: "${{ github.event_name }} - ${{ github.actor }}" |
4 | 5 | on: |
5 | | - schedule: |
6 | | - - cron: "0 0 * * 0" # Runs weekly on Sunday at midnight |
7 | | - workflow_dispatch: |
8 | | - inputs: |
9 | | - threshold-days: |
10 | | - description: "Number of days to keep container versions" |
11 | | - required: false |
12 | | - default: "7" |
13 | | - included-tags: |
14 | | - description: "Tags to include for deletion" |
15 | | - required: false |
16 | | - default: "*" |
17 | | - excluded-tags: |
18 | | - description: "Tags to exclude from deletion" |
19 | | - required: false |
20 | | - default: "latest,release*,*.*" |
21 | | - dry-run: |
22 | | - description: "Enable dry-run mode" |
23 | | - required: false |
24 | | - default: "false" |
25 | | - type: "boolean" |
26 | | - debug: |
27 | | - description: "Enable debug mode" |
28 | | - required: false |
29 | | - default: "false" |
30 | | - type: "boolean" |
| 6 | + schedule: |
| 7 | + - cron: "0 0 * * 0" # Runs weekly on Sunday at midnight |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + threshold-days: |
| 11 | + description: "Number of days to keep container versions" |
| 12 | + required: false |
| 13 | + default: "7" |
| 14 | + included-tags: |
| 15 | + description: "Tags to include for deletion" |
| 16 | + required: false |
| 17 | + default: "*" |
| 18 | + excluded-tags: |
| 19 | + description: "Tags to exclude from deletion" |
| 20 | + required: false |
| 21 | + default: "release*,semver,main,latest" |
| 22 | + dry-run: |
| 23 | + description: "Enable dry-run mode" |
| 24 | + required: false |
| 25 | + default: true |
| 26 | + type: boolean |
| 27 | + debug: |
| 28 | + description: "Enable debug mode" |
| 29 | + required: false |
| 30 | + default: false |
| 31 | + type: boolean |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
31 | 35 | jobs: |
32 | | - cleanup: |
33 | | - runs-on: ubuntu-latest |
| 36 | + cleanup: |
| 37 | + env: |
| 38 | + GITHUB_EVENT_NAME: ${{ github.event_name }} |
| 39 | + GITHUB_ACTOR: ${{ github.actor }} |
| 40 | + THRESHOLD_DAYS: ${{ github.event.inputs.threshold-days || 7 }} |
| 41 | + INCLUDED_TAGS: ${{ github.event.inputs.included-tags || '*' }} |
| 42 | + EXCLUDED_TAGS: ${{ github.event.inputs.excluded-tags || 'latest,release*,*.*,semver,main' }} |
| 43 | + DRY_RUN: ${{ github.event.inputs.dry-run || 'false' }} |
| 44 | + DEBUG: ${{ github.event.inputs.debug || 'false' }} |
| 45 | + name: "Cleanup Old Docker Container Versions" |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - name: "Summary" |
| 49 | + run: | |
| 50 | + echo "**Event**: $GITHUB_EVENT_NAME" |
| 51 | + echo "**Actor**: $GITHUB_ACTOR" |
| 52 | + echo "**Threshold days**: $THRESHOLD_DAYS" |
| 53 | + echo "**Included tags**: $INCLUDED_TAGS" |
| 54 | + echo "**Excluded tags**: $EXCLUDED_TAGS" |
| 55 | + echo "**Dry-run**: $DRY_RUN" |
| 56 | + echo "**Debug**: $DEBUG" |
34 | 57 |
|
35 | | - steps: |
36 | | - - name: "Summary" |
37 | | - run: | |
38 | | - echo "**Event**: ${{ github.event_name }}" |
39 | | - echo "**Actor**: ${{ github.actor }}" |
40 | | - echo "**Threshold days**: ${{ github.event.inputs.threshold-days || 8 }}" |
41 | | - echo "**Included tags**: ${{ github.event.inputs.included-tags || '*' }}" |
42 | | - echo "**Excluded tags**: ${{ github.event.inputs.excluded-tags || 'latest,release*,*.*' }}" |
43 | | - echo "**Dry-run**: ${{ github.event.inputs.dry-run || 'false' }}" |
44 | | - echo "**Debug**: ${{ github.event.inputs.debug || 'false' }}" |
45 | | - - name: Run Container Package Cleanup Action |
46 | | - uses: netcracker/qubership-workflow-hub/actions/container-package-cleanup@v2.0.5 |
47 | | - with: |
48 | | - threshold-days: ${{ github.event.inputs.threshold-days || 8 }} |
49 | | - included-tags: ${{ github.event.inputs.included-tags || '*' }} |
50 | | - excluded-tags: ${{ github.event.inputs.excluded-tags || 'latest,release*,*.*' }} |
51 | | - dry-run: ${{ github.event.inputs.dry-run || 'false' }} |
52 | | - debug: ${{ github.event.inputs.debug || 'false' }} |
53 | | - env: |
54 | | - PACKAGE_TOKEN: ${{ secrets.GH_RWD_PACKAGE_TOKEN }} |
| 58 | + - name: "Run Container Package Cleanup Action" |
| 59 | + uses: netcracker/qubership-workflow-hub/actions/container-package-cleanup@396774180000abdb825cbf150b56cc59c6913db8 #v2.0.5 |
| 60 | + with: |
| 61 | + threshold-days: ${{ env.THRESHOLD_DAYS }} |
| 62 | + included-tags: ${{ env.INCLUDED_TAGS }} |
| 63 | + excluded-tags: ${{ env.EXCLUDED_TAGS }} |
| 64 | + dry-run: ${{ env.DRY_RUN }} |
| 65 | + debug: ${{ env.DEBUG }} |
| 66 | + env: |
| 67 | + PACKAGE_TOKEN: ${{ secrets.GH_RWD_PACKAGE_TOKEN }} |
0 commit comments