ci: schedule development image releases
This commit is contained in:
1 parent
e567811dfb
commit
46b1dc94e1
2 files changed
+75
-61
No files matched your search
@@ -1,61 +0,0 @@
|
|||||||
name: Build Docker Image - Dev
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: docker.lechner-systems.at
|
|
||||||
IMAGE_NAME: lechnersystems/maintenance
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Read version
|
|
||||||
id: version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
version="$(git rev-parse --short=12 HEAD)"
|
|
||||||
|
|
||||||
if [[ ! "$version" =~ ^[0-9a-f]{12}$ ]]; then
|
|
||||||
echo "Invalid git hash version: $version" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "value=$version" >> "$GITEA_OUTPUT"
|
|
||||||
echo "docker_tag=$version" >> "$GITEA_OUTPUT"
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
|
||||||
|
|
||||||
- name: Build and push dev image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
provenance: false
|
|
||||||
build-args: |
|
|
||||||
APP_VERSION=${{ gitea.sha }}
|
|
||||||
VCS_REF=${{ gitea.run_number }}
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
|
|
||||||
labels: |
|
|
||||||
org.opencontainers.image.version=${{ gitea.sha }}
|
|
||||||
org.opencontainers.image.revision=${{ gitea.run_number }}
|
|
||||||
org.opencontainers.image.source=${{ gitea.repositoryUrl }}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
name: Release Development
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 23 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
actions: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: docker.lechner-systems.at
|
||||||
|
IMAGE_NAME: lechnersystems/maintenance
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
changes:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
changed: ${{ steps.check.outputs.changed }}
|
||||||
|
steps:
|
||||||
|
- name: Check for commits since previous successful development release
|
||||||
|
id: check
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
GITEA_API_URL: ${{ gitea.api_url }}
|
||||||
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
|
GITEA_SHA: ${{ gitea.sha }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
runs_url="$GITEA_API_URL/repos/$GITEA_REPOSITORY/actions/runs?limit=100"
|
||||||
|
runs="$(curl --fail --silent --show-error --header "Authorization: token $GITEA_TOKEN" "$runs_url")"
|
||||||
|
previous_sha="$(jq -r --arg path '.gitea/workflows/ReleaseDevelopment.yml' '[.workflow_runs[] | select(.path == $path and .status == "success")][0].head_sha // empty' <<< "$runs")"
|
||||||
|
|
||||||
|
if [ "$previous_sha" = "$GITEA_SHA" ]; then
|
||||||
|
echo 'changed=false' >> "$GITEA_OUTPUT"
|
||||||
|
echo 'No changes since previous successful development release.'
|
||||||
|
else
|
||||||
|
echo 'changed=true' >> "$GITEA_OUTPUT"
|
||||||
|
echo 'Changes found; development release will run.'
|
||||||
|
fi
|
||||||
|
|
||||||
|
image:
|
||||||
|
needs: changes
|
||||||
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push development image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
provenance: false
|
||||||
|
build-args: |
|
||||||
|
APP_VERSION=${{ gitea.sha }}
|
||||||
|
VCS_REF=${{ gitea.sha }}
|
||||||
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.version=${{ gitea.sha }}
|
||||||
|
org.opencontainers.image.revision=${{ gitea.sha }}
|
||||||
|
org.opencontainers.image.source=${{ gitea.repositoryUrl }}
|
||||||
|
|
||||||
Reference in new issue
Block a user