50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
name: Build and publish Boutmoun Docker image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ghaymah2
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Verify Docker is available
|
|
run: docker info
|
|
|
|
- name: Log in to GitPasha Container Registry
|
|
env:
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
if [ -z "$REGISTRY_USERNAME" ] || [ -z "$REGISTRY_TOKEN" ]; then
|
|
echo 'Configure REGISTRY_USERNAME and REGISTRY_TOKEN in repository Actions secrets.' >&2
|
|
exit 1
|
|
fi
|
|
printf '%s' "$REGISTRY_TOKEN" | docker login app.gitpasha.com --username "$REGISTRY_USERNAME" --password-stdin
|
|
|
|
- name: Build and push Linux/amd64 image
|
|
env:
|
|
IMAGE: app.gitpasha.com/boutmoun/gracesalmoun
|
|
COMMIT_SHA: ${{ gitea.sha }}
|
|
run: |
|
|
set -eu
|
|
SHA_TAG="sha-${COMMIT_SHA}"
|
|
docker build --pull --platform linux/amd64 \
|
|
-t "${IMAGE}:${SHA_TAG}" \
|
|
-t "${IMAGE}:latest" \
|
|
.
|
|
docker push "${IMAGE}:${SHA_TAG}"
|
|
docker push "${IMAGE}:latest"
|
|
echo "Published ${IMAGE}:${SHA_TAG}"
|
|
echo "Published ${IMAGE}:latest"
|
|
|
|
- name: Log out of registry
|
|
if: always()
|
|
run: docker logout app.gitpasha.com || true
|