Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Image

Image #71

Workflow file for this run

name: "Latest image"
on:
workflow_dispatch:
schedule:
- cron: '42 5 15 * *' # At 05:42 on day-of-month 15.
jobs:
docker:
name: Build Docker images
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up Docker Buildx 🔧
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers 💾
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push CLI image 🧪
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: ghcr.io/cyclenerd/scp-tools-gitlab:test
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
docker-test:
name: Test Docker image
needs: [docker]
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Login to GitHub Container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull CLI test image 💿
run: |
docker pull ghcr.io/cyclenerd/scp-tools-gitlab:test
docker tag ghcr.io/cyclenerd/scp-tools-gitlab:test scp-tools-gitlab
# Run tests
- name: Test Java versions 📏
run: docker run scp-tools-gitlab java --version
- name: Test Cloud Foundry CLI versions 📏
run: docker run scp-tools-gitlab cf --version
- name: Test Neo Environment SDK versions 📏
run: docker run scp-tools-gitlab neo.sh version
- name: Test Cloud MTA Build Tool versions 📏
run: docker run scp-tools-gitlab mbt --version
- name: Test MkDocs versions 📏
run: docker run scp-tools-gitlab mkdocs --version
github-registry-latest:
name: Push image to GitHub
runs-on: ubuntu-latest
needs: [docker-test]
steps:
- name: Login to GitHub Container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull latest test image from GitHub container registry 📦
run: docker pull ghcr.io/cyclenerd/scp-tools-gitlab:test
- name: Quick test 📏
run: docker run ghcr.io/cyclenerd/scp-tools-gitlab:test java --version
- name: Push image to GitHub container registry as latest version 🚢
run: |
docker tag ghcr.io/cyclenerd/scp-tools-gitlab:test ghcr.io/cyclenerd/scp-tools-gitlab:latest
docker push ghcr.io/cyclenerd/scp-tools-gitlab:latest
docker-hub-latest:
name: Push image to Docker Hub
runs-on: ubuntu-latest
needs: [docker-test]
steps:
- name: Login to Docker Hub registry 🏭
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- name: Pull latest test image from GitHub container registry 📦
run: docker pull ghcr.io/cyclenerd/scp-tools-gitlab:test
- name: Quick test 📏
run: docker run ghcr.io/cyclenerd/scp-tools-gitlab:test java --version
- name: Push image to Docker Hub registry as latest version 🚢
run: |
docker tag ghcr.io/cyclenerd/scp-tools-gitlab:test cyclenerd/scp-tools-gitlab:latest
docker push cyclenerd/scp-tools-gitlab:latest
# Deletes old container images
ghcr-cleaner:
name: Registry Cleaner
runs-on: 'ubuntu-latest'
needs: [docker-hub-latest,github-registry-latest]
steps:
# As per documentation, the authentication to the GHCR registry must be done using a personal access token (PAT) to delete packages.
# Only classic tokens can be used, fined-grained ones and GITHUB_TOKEN are currently (2024-01) not supported.
# More:
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
# The recommendation is to create a new PAT with only the `read:packages` and `delete:packages` scopes.
# Create new token:
# https://github.com/settings/tokens/new?scopes=read:packages,delete:packages
# List personal access tokens:
# https://github.com/settings/tokens
#
# https://github.com/marketplace/actions/ghcr-cleaner
# Forked from: https://github.com/Chizkiyahu/delete-untagged-ghcr-action
- name: GHCR 🚮
uses: quartx-analytics/ghcr-cleaner@v1
with:
token: ${{ secrets.PAT_TOKEN }}
repository-owner: ${{ github.repository_owner }}
repository-name: ${{ github.repository }}
owner-type: user
delete-untagged: true