This commit is contained in:
parent
a40a9a44ea
commit
7db37b13e6
1 changed files with 7 additions and 42 deletions
|
@ -1,36 +1,20 @@
|
||||||
name: docker
|
name: docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# workflow_run:
|
|
||||||
# workflows: [crane]
|
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
# types:
|
|
||||||
# - completed
|
|
||||||
# schedule:
|
|
||||||
# - cron: 0 0 * * 1
|
|
||||||
# # Publish semver tags as releases.
|
|
||||||
# tags: [ 'v*.*.*' ]
|
|
||||||
# pull_request:
|
|
||||||
# branches: [ "main" ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Use docker.io for Docker Hub if empty
|
|
||||||
REGISTRY: git.nexveridian.com
|
REGISTRY: git.nexveridian.com
|
||||||
# github.repository as <account>/<repo>
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
NIX_CONFIG: "experimental-features = nix-command flakes"
|
NIX_CONFIG: "experimental-features = nix-command flakes"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
|
|
||||||
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
# This is used to complete the identity challenge
|
|
||||||
# with sigstore/fulcio when running outside of PRs.
|
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -48,42 +32,23 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Docker
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.local/bin
|
|
||||||
nix build -I nixpkgs=channel:nixos-unstable nixpkgs#docker -o ~/.local/docker
|
|
||||||
ln -sf ~/.local/docker/bin/docker ~/.local/bin/docker
|
|
||||||
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- name: Log into registry ${{ env.REGISTRY }}
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ env.GITHUB_ACTOR }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ env.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
|
|
||||||
- name: Build Nix package
|
- name: Build Nix package
|
||||||
run: nix build .#my-docker
|
run: nix build .#my-docker
|
||||||
|
|
||||||
# https://github.com/orgs/community/discussions/25768#discussioncomment-3249183
|
- name: Prepare repository variables
|
||||||
- name: Downcase REPO
|
|
||||||
run: |
|
run: |
|
||||||
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
|
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
|
||||||
|
STRIP_REPO_USERNAME=${GITHUB_REPOSITORY,,#nexveridian/}
|
||||||
- name: Strip REPO Username
|
|
||||||
run: |
|
|
||||||
STRIP_REPO_USERNAME=${REPO#nexveridian/}
|
|
||||||
echo "STRIP_REPO_USERNAME=${STRIP_REPO_USERNAME}" >> ${GITHUB_ENV}
|
echo "STRIP_REPO_USERNAME=${STRIP_REPO_USERNAME}" >> ${GITHUB_ENV}
|
||||||
|
|
||||||
# https://github.com/docker/build-push-action/issues/538
|
- name: Load, tag and push Docker image
|
||||||
- name: Push and tag Docker image
|
|
||||||
run: |
|
run: |
|
||||||
docker load < result
|
docker load < result
|
||||||
docker tag ${{ env.STRIP_REPO_USERNAME }}:latest ${{ env.REGISTRY }}/${{ env.REPO }}:latest
|
docker tag ${{ env.STRIP_REPO_USERNAME }}:latest ${{ env.REGISTRY }}/${{ env.REPO }}:latest
|
||||||
|
@ -100,7 +65,7 @@ jobs:
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$valid_paths" ]; then
|
if [ -n "$valid_paths" ]; then
|
||||||
for i in {1..10}; do
|
for i in {1..3}; do
|
||||||
nix run -I nixpkgs=channel:nixos-unstable nixpkgs#attic-client push nexveridian-web $valid_paths && break || [ $i -eq 5 ] || sleep 5
|
nix run -I nixpkgs=channel:nixos-unstable nixpkgs#attic-client push nexveridian-web $valid_paths && break || [ $i -eq 3 ] || sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue