Skip to content

Instantly share code, notes, and snippets.

@nbeck415
Last active August 2, 2024 23:36
Show Gist options
  • Select an option

  • Save nbeck415/5182b3597f889da740e57f8707311219 to your computer and use it in GitHub Desktop.

Select an option

Save nbeck415/5182b3597f889da740e57f8707311219 to your computer and use it in GitHub Desktop.

Revisions

  1. nbeck415 revised this gist Sep 5, 2023. 3 changed files with 3 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion build_and_push_docker_hub.yaml
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ jobs:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    uses: actions/checkout@v3

    - name: Log in to Docker Hub
    run: |
    2 changes: 1 addition & 1 deletion build_and_push_ghcr.yaml
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ jobs:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    uses: actions/checkout@v3

    - name: Log in to ghcr.io
    run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
    2 changes: 1 addition & 1 deletion build_and_push_harbor.yaml
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ jobs:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    uses: actions/checkout@v3

    - name: Log in to Harbor
    run: |
  2. nbeck415 revised this gist Aug 30, 2023. 3 changed files with 23 additions and 23 deletions.
    24 changes: 12 additions & 12 deletions build_and_push_docker_hub.yaml
    Original file line number Diff line number Diff line change
    @@ -8,17 +8,17 @@ jobs:
    push_to_docker_hub:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Log in to Docker Hub
    run: |
    echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
    - name: Build and tag image
    run: |
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Log in to Docker Hub
    run: |
    echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
    - name: Push image to Docker Hub
    run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA
    - name: Build and tag image
    run: |
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Push image to Docker Hub
    run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA
    6 changes: 3 additions & 3 deletions build_and_push_ghcr.yaml
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,9 @@ jobs:
    push_to_ghcr:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Log in to ghcr.io
    run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

    16 changes: 8 additions & 8 deletions build_and_push_harbor.yaml
    Original file line number Diff line number Diff line change
    @@ -12,13 +12,13 @@ jobs:
    uses: actions/checkout@v2

    - name: Log in to Harbor
    run: |
    echo ${{ secrets.HARBOR_CREDENTIALS }} | base64 --decode | docker login -u $(cut -d ':' -f1 <<< "${{ secrets.HARBOR_CREDENTIALS }}") --password-stdin ${{ secrets.HARBOR_REGISTRY_URL }}
    run: |
    echo ${{ secrets.HARBOR_CREDENTIALS }} | base64 --decode | docker login -u $(cut -d ':' -f1 <<< "${{ secrets.HARBOR_CREDENTIALS }}") --password-stdin ${{ secrets.HARBOR_REGISTRY_URL }}
    - name: Build and tag image
    run: |
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Build and tag image
    run: |
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Push image to Harbor
    run: docker push ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA
    - name: Push image to Harbor
    run: docker push ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA
  3. nbeck415 revised this gist Aug 30, 2023. 3 changed files with 17 additions and 14 deletions.
    12 changes: 7 additions & 5 deletions build_and_push_docker_hub.yaml
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,8 @@ on:
    - main

    jobs:
    build:
    push_to_docker_hub:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    @@ -16,7 +15,10 @@ jobs:
    run: |
    echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
    - name: Build and push image to Docker Hub
    - name: Build and tag image
    run: |
    docker build -t dockerhub-username/image-name:latest -f path/to/Dockerfile .
    docker push dockerhub-username/image-name:latest
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Push image to Docker Hub
    run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:$COMMIT_SHA
    11 changes: 7 additions & 4 deletions build_and_push_ghcr.yaml
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ on:
    - main

    jobs:
    build:
    push_to_ghcr:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    @@ -14,7 +14,10 @@ jobs:
    - name: Log in to ghcr.io
    run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

    - name: Build and push image to GHCR
    - name: Build and tag image
    run: |
    docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest -f path/to/Dockerfile .
    docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Push image to GHCR
    run: docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:$COMMIT_SHA
    8 changes: 3 additions & 5 deletions build_and_push_harbor.yaml
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@ on:
    jobs:
    push_to_harbor:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
    uses: actions/checkout@v2
    @@ -18,9 +17,8 @@ jobs:
    - name: Build and tag image
    run: |
    docker build -t image-name:latest .
    docker tag image-name:latest ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/repo-name:latest
    COMMIT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
    docker build -t ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA -f path/to/Dockerfile .
    - name: Push image to Harbor
    run: |
    docker push ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/repo-name:latest
    run: docker push ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/${{ github.repository }}:$COMMIT_SHA
  4. nbeck415 revised this gist Aug 23, 2023. No changes.
  5. nbeck415 created this gist Aug 23, 2023.
    22 changes: 22 additions & 0 deletions build_and_push_docker_hub.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    name: Build and push to Docker Hub
    on:
    push:
    branches:
    - main

    jobs:
    build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Log in to Docker Hub
    run: |
    echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
    - name: Build and push image to Docker Hub
    run: |
    docker build -t dockerhub-username/image-name:latest -f path/to/Dockerfile .
    docker push dockerhub-username/image-name:latest
    20 changes: 20 additions & 0 deletions build_and_push_ghcr.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    name: Build and push to GHCR
    on:
    push:
    branches:
    - main

    jobs:
    build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Log in to ghcr.io
    run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

    - name: Build and push image to GHCR
    run: |
    docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest -f path/to/Dockerfile .
    docker push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest
    26 changes: 26 additions & 0 deletions build_and_push_harbor.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    name: Build and push to Harbor
    on:
    push:
    branches:
    - main

    jobs:
    push_to_harbor:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
    uses: actions/checkout@v2

    - name: Log in to Harbor
    run: |
    echo ${{ secrets.HARBOR_CREDENTIALS }} | base64 --decode | docker login -u $(cut -d ':' -f1 <<< "${{ secrets.HARBOR_CREDENTIALS }}") --password-stdin ${{ secrets.HARBOR_REGISTRY_URL }}
    - name: Build and tag image
    run: |
    docker build -t image-name:latest .
    docker tag image-name:latest ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/repo-name:latest
    - name: Push image to Harbor
    run: |
    docker push ${{ secrets.HARBOR_REGISTRY_URL }}/project-name/repo-name:latest