Skip to content

Commit

Permalink
Ghcr (#6)
Browse files Browse the repository at this point in the history
* push to ghcr aswell as dockerhub
  • Loading branch information
Amateur-God authored Jun 29, 2024
1 parent 8d17f48 commit 9a521b3
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 51 deletions.
131 changes: 82 additions & 49 deletions .github/workflows/CI-CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,50 +179,6 @@
with:
config: .yamllint

lint-prettier:
name: Prettier
if: github.ref != 'refs/heads/main' && github.event_name == 'push'
needs: information
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.information.outputs.addon_dirs) }}
steps:
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Debug - Print addon_dirs
run: |
echo "addon_dirs: ${{ needs.information.outputs.addon_dirs }}"
- name: Debug - Print matrix folder path
run: |
echo "Matrix folder path: ${{ matrix.folder }}"
- name: Run Prettier
uses: creyD/[email protected]
with:
prettier_options: --write ./${{ matrix.folder }}/**/*.{json,js,md,yaml}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add ./${{ matrix.folder }}/config.json ./${{ matrix.folder }}/build.json
if ! git diff-index --quiet HEAD; then
git commit -m "Prettified Code!"
git fetch origin
git rebase origin/${{ github.ref }}
if [ $? -ne 0 ]; then
echo "Rebase failed, attempting to resolve conflicts"
git rebase --abort
git pull origin ${{ github.ref }}
fi
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }}
else
echo "No changes to commit"
fi
build_main_or_pr:
name: Build ${{ matrix.architecture }} (Main or PR)
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request')
Expand Down Expand Up @@ -269,6 +225,12 @@
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Compose build flags
Expand Down Expand Up @@ -330,6 +292,7 @@
BUILD_VERSION=${{ needs.information.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
ghcr.io/${{ steps.convert.outputs.repository_owner_lower }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
- name: Swap build cache
run: |
if [ -d /tmp/.docker-cache-new ]; then
Expand All @@ -348,7 +311,6 @@
- lint-json
- lint-shellcheck
- lint-yamllint
- lint-prettier
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -390,6 +352,12 @@
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Compose build flags
Expand Down Expand Up @@ -451,6 +419,7 @@
BUILD_VERSION=${{ needs.information.outputs.version }}
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
ghcr.io/${{ steps.convert.outputs.repository_owner_lower }}/${{ steps.convert.outputs.slug_lower }}:${{ steps.set_version.outputs.version }}-${{ matrix.architecture }}
- name: Swap build cache
run: |
if [ -d /tmp/.docker-cache-new ]; then
Expand All @@ -476,7 +445,12 @@
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and Push Docker Manifest latest
run: |
IMAGE_NAME="${{ secrets.DOCKER_USERNAME }}/${{ needs.build_main_or_pr.outputs.slug_lower }}"
Expand All @@ -494,6 +468,31 @@
IMAGE_NAME="${{ secrets.DOCKER_USERNAME }}/${{ needs.build_main_or_pr.outputs.slug_lower }}"
VERSION="${{ needs.build_main_or_pr.outputs.version }}"
docker buildx imagetools create \
-t $IMAGE_NAME:$VERSION \
$IMAGE_NAME:$VERSION-amd64 \
$IMAGE_NAME:$VERSION-aarch64 \
$IMAGE_NAME:$VERSION-armhf \
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
- name: Create and Push Docker Manifest latest to GHCR
run: |
IMAGE_NAME="ghcr.io/${{ needs.build_main_or_pr.outputs.repository_owner_lower }}/${{ needs.build_main_or_pr.outputs.slug_lower }}"
VERSION="${{ needs.build_main_or_pr.outputs.version }}"
docker buildx imagetools create \
-t $IMAGE_NAME:latest \
$IMAGE_NAME:$VERSION-amd64 \
$IMAGE_NAME:$VERSION-aarch64 \
$IMAGE_NAME:$VERSION-armhf \
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
- name: Create and Push Docker Manifest Version to GHCR
run: |
IMAGE_NAME="ghcr.io/${{ needs.build_main_or_pr.outputs.repository_owner_lower }}/${{ needs.build_main_or_pr.outputs.slug_lower }}"
VERSION="${{ needs.build_main_or_pr.outputs.version }}"
docker buildx imagetools create \
-t $IMAGE_NAME:$VERSION \
$IMAGE_NAME:$VERSION-amd64 \
Expand All @@ -503,7 +502,7 @@
$IMAGE_NAME:$VERSION-armv7
create_and_push_manifest_dev:
name: Create and Push Docker Manifest
name: Create and Push Docker Manifest (Development)
runs-on: ubuntu-latest
needs: build_other_branches
steps:
Expand All @@ -519,7 +518,14 @@
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create and Push Docker Manifest dev
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and Push Docker Manifest dev to DockerHub
run: |
IMAGE_NAME="${{ secrets.DOCKER_USERNAME }}/${{ needs.build_other_branches.outputs.slug_lower }}"
VERSION="${{ needs.build_other_branches.outputs.version }}"
Expand All @@ -532,7 +538,7 @@
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
- name: Create and Push Docker Manifest version
- name: Create and Push Docker Manifest version to DockerHub
run: |
IMAGE_NAME="${{ secrets.DOCKER_USERNAME }}/${{ needs.build_other_branches.outputs.slug_lower }}"
VERSION="${{ needs.build_other_branches.outputs.version }}"
Expand All @@ -545,6 +551,33 @@
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
- name: Create and Push Docker Manifest dev to GHCR
run: |
IMAGE_NAME="ghcr.io/${{ needs.build_other_branches.outputs.repository_owner_lower }}/${{ needs.build_other_branches.outputs.slug_lower }}"
VERSION="${{ needs.build_other_branches.outputs.version }}"
docker buildx imagetools create \
-t $IMAGE_NAME:DEV \
$IMAGE_NAME:$VERSION-amd64 \
$IMAGE_NAME:$VERSION-aarch64 \
$IMAGE_NAME:$VERSION-armhf \
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
- name: Create and Push Docker Manifest version to GHCR
run: |
IMAGE_NAME="ghcr.io/${{ needs.build_other_branches.outputs.repository_owner_lower }}/${{ needs.build_other_branches.outputs.slug_lower }}"
VERSION="${{ needs.build_other_branches.outputs.version }}"
docker buildx imagetools create \
-t $IMAGE_NAME:$VERSION \
$IMAGE_NAME:$VERSION-amd64 \
$IMAGE_NAME:$VERSION-aarch64 \
$IMAGE_NAME:$VERSION-armhf \
$IMAGE_NAME:$VERSION-i386 \
$IMAGE_NAME:$VERSION-armv7
update_config_main_or_pr:
runs-on: ubuntu-latest
needs: build_main_or_pr
Expand Down
2 changes: 1 addition & 1 deletion addons/adb_server/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"BUILD_REF": "main",
"BUILD_REPOSITORY": "github.com/Amateur-God/Hassio-Addons",
"BUILD_VERSION": "1.1.1",
"DEV_BUILD_DATE": "2024-06-29T15:22:09Z"
"DEV_BUILD_DATE": "2024-06-29T15:53:38Z"
}
}
2 changes: 1 addition & 1 deletion addons/adb_server/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ADB Server",
"version": "1.1.1",
"version": "dev-1.1.1",
"slug": "adb_server",
"description": "A Home Assistant add-on for ADB Server with restricted shell access.",
"arch": [
Expand Down

0 comments on commit 9a521b3

Please sign in to comment.