Skip to content

Commit

Permalink
User native actions for docker build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
navhits committed Jun 18, 2023
1 parent 7b61761 commit a9f4c8a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 59 deletions.
35 changes: 20 additions & 15 deletions .github/workflows/awesomeapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ jobs:
awesomeapi-image-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Building Docker Image
run: |
DOCKER_REGISTRY="ghcr.io"
GH_OWNER=$(echo $GITHUB_REPOSITORY | cut -f1 -d\/)
GH_REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -f2 -d\/)
GH_BRANCH=$(echo $GITHUB_REF | rev | cut -f1 -d\/ | rev)
DOCKER_IMAGE="$DOCKER_REGISTRY/$GH_OWNER/$GH_REPO_NAME/awesomeapi"
echo $GITHUB_TOKEN | docker login -u $GITHUB_ACTOR --password-stdin $DOCKER_REGISTRY
docker build -t $DOCKER_IMAGE:$GH_BRANCH -f "./awesomeapi/Dockerfile" "./awesomeapi/"
docker push $DOCKER_IMAGE:$GH_BRANCH
docker logout $DOCKER_REGISTRY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and push
uses: docker/build-push-action@v3
with:
context: .
file: awesomeapi/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/awesomeapi:latest
35 changes: 20 additions & 15 deletions .github/workflows/awesomecli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ jobs:
awesomecli-image-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Building Docker Image
run: |
DOCKER_REGISTRY="ghcr.io"
GH_OWNER=$(echo $GITHUB_REPOSITORY | cut -f1 -d\/)
GH_REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -f2 -d\/)
GH_BRANCH=$(echo $GITHUB_REF | rev | cut -f1 -d\/ | rev)
DOCKER_IMAGE="$DOCKER_REGISTRY/$GH_OWNER/$GH_REPO_NAME/awesomecli"
echo $GITHUB_TOKEN | docker login -u $GITHUB_ACTOR --password-stdin $DOCKER_REGISTRY
docker build -t $DOCKER_IMAGE:$GH_BRANCH -f "./awesomecli/Dockerfile" "./awesomecli/"
docker push $DOCKER_IMAGE:$GH_BRANCH
docker logout $DOCKER_REGISTRY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and push
uses: docker/build-push-action@v3
with:
context: .
file: awesomecli/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/awesomecli:latest
34 changes: 20 additions & 14 deletions .github/workflows/helloworld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ jobs:
helloworld-image-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Building Docker Image
run: |
DOCKER_REGISTRY="ghcr.io"
GH_OWNER=$(echo $GITHUB_REPOSITORY | cut -f1 -d\/)
GH_REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -f2 -d\/)
GH_BRANCH=$(echo $GITHUB_REF | rev | cut -f1 -d\/ | rev)
DOCKER_IMAGE="$DOCKER_REGISTRY/$GH_OWNER/$GH_REPO_NAME/helloworld"
echo $GITHUB_TOKEN | docker login -u $GITHUB_ACTOR --password-stdin $DOCKER_REGISTRY
docker build -t $DOCKER_IMAGE:$GH_BRANCH -f "./helloworld/Dockerfile" "./helloworld/"
docker push $DOCKER_IMAGE:$GH_BRANCH
docker logout $DOCKER_REGISTRY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and push
uses: docker/build-push-action@v3
with:
context: .
file: helloworld/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/helloworld:latest
35 changes: 20 additions & 15 deletions .github/workflows/pydependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ jobs:
pydependencies-image-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Building Docker Image
run: |
DOCKER_REGISTRY="ghcr.io"
GH_OWNER=$(echo $GITHUB_REPOSITORY | cut -f1 -d\/)
GH_REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -f2 -d\/)
GH_BRANCH=$(echo $GITHUB_REF | rev | cut -f1 -d\/ | rev)
DOCKER_IMAGE="$DOCKER_REGISTRY/$GH_OWNER/$GH_REPO_NAME/pydependencies"
echo $GITHUB_TOKEN | docker login -u $GITHUB_ACTOR --password-stdin $DOCKER_REGISTRY
docker build -t $DOCKER_IMAGE:$GH_BRANCH -f "./pydependencies/Dockerfile" "./pydependencies/"
docker push $DOCKER_IMAGE:$GH_BRANCH
docker logout $DOCKER_REGISTRY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and push
uses: docker/build-push-action@v3
with:
context: .
file: pydependencies/Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/pydependencies:latest

0 comments on commit a9f4c8a

Please sign in to comment.