retention temp artifakteille
This commit is contained in:
@@ -85,10 +85,11 @@ jobs:
|
|||||||
echo "artifact_exists=$ARTIFACT_EXISTS" >> "$GITHUB_OUTPUT"
|
echo "artifact_exists=$ARTIFACT_EXISTS" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Upload build env artifact
|
- name: Upload build env artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx/build.env
|
path: /tmp/build-ctx/build.env
|
||||||
|
retention-days: 0 # <--- Poistaa suuren .tar-tiedoston automaattisesti heti kun putki on valmis
|
||||||
|
|
||||||
- name: Set Gitea status to SUCCESS
|
- name: Set Gitea status to SUCCESS
|
||||||
if: success()
|
if: success()
|
||||||
@@ -123,7 +124,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download build env
|
- name: Download build env
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
@@ -176,10 +177,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload Docker image artifact
|
- name: Upload Docker image artifact
|
||||||
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
if: steps.gatekeeper.outputs.skip == 'false' && success()
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@4
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp/image/artifact.tar
|
path: /tmp/image/artifact.tar
|
||||||
|
retention-days: 0 # <--- Poistaa suuren .tar-tiedoston automaattisesti heti kun putki on valmis
|
||||||
|
|
||||||
push:
|
push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -189,7 +191,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download build env
|
- name: Download build env
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@4
|
||||||
with:
|
with:
|
||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
@@ -211,7 +213,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Load saved Docker image
|
- name: Load saved Docker image
|
||||||
if: steps.gatekeeper.outputs.skip == 'false'
|
if: steps.gatekeeper.outputs.skip == 'false'
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docker-image
|
name: docker-image
|
||||||
path: /tmp/image
|
path: /tmp/image
|
||||||
@@ -259,47 +261,6 @@ jobs:
|
|||||||
source /tmp/build-ctx/build.env
|
source /tmp/build-ctx/build.env
|
||||||
bash scripts/report-status.sh failure "Docker push $NEXT_VERSION FAILED" ci-docker-push
|
bash scripts/report-status.sh failure "Docker push $NEXT_VERSION FAILED" ci-docker-push
|
||||||
|
|
||||||
- name: Delete Docker image artifact from Gitea (Python)
|
|
||||||
if: always()
|
|
||||||
shell: python
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
SERVER_URL: ${{ gitea.server_url }}
|
|
||||||
REPOSITORY: ${{ gitea.repository }}
|
|
||||||
RUN_ID: ${{ gitea.run_id }}
|
|
||||||
ARTIFACT_NAME: "docker-image"
|
|
||||||
run: |
|
|
||||||
import os, urllib.request, json
|
|
||||||
|
|
||||||
token = os.environ['GITEA_TOKEN']
|
|
||||||
server = os.environ['SERVER_URL']
|
|
||||||
repo = os.environ['REPOSITORY']
|
|
||||||
run_id = os.environ['RUN_ID']
|
|
||||||
target_name = os.environ['ARTIFACT_NAME']
|
|
||||||
|
|
||||||
# 1. Haetaan listaus artifakteista
|
|
||||||
url = f"{server}/api/v1/repos/{repo}/actions/runs/{run_id}/artifacts"
|
|
||||||
req = urllib.request.Request(url, headers={"Authorization": f"token {token}"})
|
|
||||||
|
|
||||||
try:
|
|
||||||
with urllib.request.urlopen(req) as response:
|
|
||||||
data = json.loads(response.read().decode())
|
|
||||||
|
|
||||||
# 2. Etsitään oikea ID
|
|
||||||
artifacts = data.get("artifacts", [])
|
|
||||||
artifact_id = next((a["id"] for a in artifacts if a["name"] == target_name), None)
|
|
||||||
|
|
||||||
# 3. Jos löytyi, lähetetään DELETE-pyyntö
|
|
||||||
if artifact_id:
|
|
||||||
del_url = f"{server}/api/v1/repos/{repo}/actions/artifacts/{artifact_id}"
|
|
||||||
del_req = urllib.request.Request(del_url, headers={"Authorization": f"token {token}"}, method="DELETE")
|
|
||||||
with urllib.request.urlopen(del_req) as del_res:
|
|
||||||
print(f"Artifakti {target_name} (ID: {artifact_id}) poistettu onnistuneesti levyltä.")
|
|
||||||
else:
|
|
||||||
print(f"Artifaktia '{target_name}' ei löytynyt listalta. Se on jo poistettu.")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Poisto ohitettiin virheen vuoksi (esim. puuttuvat oikeudet): {e}")
|
|
||||||
|
|
||||||
tag-commit:
|
tag-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check, push]
|
needs: [check, push]
|
||||||
@@ -308,7 +269,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download build env
|
- name: Download build env
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build-context
|
name: build-context
|
||||||
path: /tmp/build-ctx
|
path: /tmp/build-ctx
|
||||||
|
|||||||
Reference in New Issue
Block a user