Skip to content

Commit

Permalink
fixeeed?
Browse files Browse the repository at this point in the history
  • Loading branch information
Amateur-God committed Jun 28, 2024
1 parent 24b2e1c commit 50dca93
Showing 1 changed file with 4 additions and 116 deletions.
120 changes: 4 additions & 116 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ jobs:
echo "repository_lower=$REPOSITORY_LOWER" >> $GITHUB_OUTPUT
echo "repository_owner_lower=$REPOSITORY_OWNER_LOWER" >> $GITHUB_OUTPUT
- name: Build and Push Docker image
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6.2.0
with:
push: true
Expand All @@ -330,36 +329,9 @@ jobs:
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:latest-${{ matrix.architecture }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:latest
- name: Build and Push Docker image for other branches
if: github.ref != 'refs/heads/main'
uses: docker/build-push-action@v2
with:
push: true
context: ./${{ matrix.folder }}
file: ./${{ matrix.folder }}/Dockerfile
platforms: linux/${{ matrix.architecture }}
cache-from: |
type=local,src=/tmp/.docker-cache
format('ghcr.io/{0}/{1}/{2}:edge', github.repository_owner, needs.information.outputs.slug, matrix.architecture)
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new
build-args: |
BUILD_ARCH=${{ matrix.architecture }}
BUILD_DATE=${{ steps.flags.outputs.date }}
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
BUILD_FROM=${{ steps.flags.outputs.from }}
BUILD_NAME=${{ needs.information.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ steps.convert.outputs.repository_lower }}
BUILD_VERSION=${{ needs.information.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}
- name: Output Image Digests
run: |
echo "DIGEST_AMD64=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:amd64)" >> $GITHUB_ENV
echo "DIGEST_ARM64=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:arm64)" >> $GITHUB_ENV
echo "DIGEST_ARMV7=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:armv7)" >> $GITHUB_ENV
echo "DIGEST_I386=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:386)" >> $GITHUB_ENV
echo "DIGEST_${{ matrix.architecture }}=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:${{ matrix.architecture }})" >> $GITHUB_ENV
- name: Swap build cache
run: |
if [ -d /tmp/.docker-cache-new ]; then
Expand All @@ -369,8 +341,6 @@ jobs:
echo "Cache directory /tmp/.docker-cache-new does not exist"
fi
build_other_branches:
name: Build ${{ matrix.architecture }} (Other Branches)
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
Expand Down Expand Up @@ -464,7 +434,6 @@ jobs:
echo "repository_lower=$REPOSITORY_LOWER" >> $GITHUB_OUTPUT
echo "repository_owner_lower=$REPOSITORY_OWNER_LOWER" >> $GITHUB_OUTPUT
- name: Build and Push Docker image
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6.2.0
with:
push: true
Expand All @@ -489,36 +458,9 @@ jobs:
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:latest-${{ matrix.architecture }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:latest
- name: Build and Push Docker image for other branches
if: github.ref != 'refs/heads/main'
uses: docker/build-push-action@v2
with:
push: true
context: ./${{ matrix.folder }}
file: ./${{ matrix.folder }}/Dockerfile
platforms: linux/${{ matrix.architecture }}
cache-from: |
type=local,src=/tmp/.docker-cache
format('ghcr.io/{0}/{1}/{2}:edge', github.repository_owner, needs.information.outputs.slug, matrix.architecture)
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new
build-args: |
BUILD_ARCH=${{ matrix.architecture }}
BUILD_DATE=${{ steps.flags.outputs.date }}
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
BUILD_FROM=${{ steps.flags.outputs.from }}
BUILD_NAME=${{ needs.information.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ steps.convert.outputs.repository_lower }}
BUILD_VERSION=${{ needs.information.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}
- name: Output Image Digests
run: |
echo "DIGEST_AMD64=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:amd64)" >> $GITHUB_ENV
echo "DIGEST_ARM64=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:arm64)" >> $GITHUB_ENV
echo "DIGEST_ARMV7=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:armv7)" >> $GITHUB_ENV
echo "DIGEST_I386=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:386)" >> $GITHUB_ENV
echo "DIGEST_${{ matrix.architecture }}=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ secrets.DOCKER_USERNAME }}/${{ needs.information.outputs.slug }}:${{ matrix.architecture }})" >> $GITHUB_ENV
- name: Swap build cache
run: |
if [ -d /tmp/.docker-cache-new ]; then
Expand All @@ -528,62 +470,6 @@ jobs:
echo "Cache directory /tmp/.docker-cache-new does not exist"
fi
manifest_main_or_pr:
runs-on: ubuntu-latest
needs: build_main_or_pr
if: github.ref == 'refs/heads/main'
steps:
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and Push Docker Manifest
run: |
docker manifest create ${{ secrets.DOCKER_USERNAME }}/${{ needs.build_main_or_pr.outputs.slug_lower }}:latest \
--amend $DIGEST_AMD64 \
--amend $DIGEST_ARM64 \
--amend $DIGEST_ARMV7 \
--amend $DIGEST_I386
docker manifest push ${{ secrets.DOCKER_USERNAME }}/${{ needs.build_main_or_pr.outputs.slug_lower }}:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DIGEST_AMD64: ${{ env.DIGEST_AMD64 }}
DIGEST_ARM64: ${{ env.DIGEST_ARM64 }}
DIGEST_ARMV7: ${{ env.DIGEST_ARMV7 }}
DIGEST_I386: ${{ env.DIGEST_I386 }}


manifest_other_branches:
runs-on: ubuntu-latest
needs: build_other_branches
if: github.ref != 'refs/heads/main'
steps:
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and Push Docker Manifest
run: |
docker manifest create ${{ secrets.DOCKER_USERNAME }}/${{ needs.build_other_branches.outputs.slug_lower }}:latest \
--amend $DIGEST_AMD64 \
--amend $DIGEST_ARM64 \
--amend $DIGEST_ARMV7 \
--amend $DIGEST_I386
docker manifest push ${{ secrets.DOCKER_USERNAME }}/${{ needs.build_other_branches.outputs.slug_lower }}:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DIGEST_AMD64: ${{ env.DIGEST_AMD64 }}
DIGEST_ARM64: ${{ env.DIGEST_ARM64 }}
DIGEST_ARMV7: ${{ env.DIGEST_ARMV7 }}
DIGEST_I386: ${{ env.DIGEST_I386 }}




update_config_main_or_pr:
runs-on: ubuntu-latest
needs: build_main_or_pr
Expand Down Expand Up @@ -612,6 +498,7 @@ jobs:
git commit -m "Update config.json with new image URL"
git pull --rebase origin ${{ github.ref }}
git push
fi
update_config_other_branches:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -641,3 +528,4 @@ jobs:
git commit -m "Update config.json with new image URL"
git pull --rebase origin ${{ github.ref }}
git push
fi

0 comments on commit 50dca93

Please sign in to comment.