Skip to content

Commit

Permalink
WIP: GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
vlauciani committed Sep 12, 2024
1 parent 8762c42 commit 2a71436
Showing 1 changed file with 34 additions and 66 deletions.
100 changes: 34 additions & 66 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,85 +11,59 @@ env:
IMAGE_NAME: ingv/fdsnws-fetcher

jobs:
build:
build_and_push_to_registry:
name: Build and Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Checkout code the repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Log in to Docker Hub
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Build Docker image
uses: docker/build-push-action@v5
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ env.IMAGE_NAME }}:latest
platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/image.tar

- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: docker-image
path: /tmp/image.tar

- name: Upload README.md
uses: actions/upload-artifact@v4
with:
name: readme
path: README.md

# list of Docker images to use as base name for tags
images: |
${{ env.IMAGE_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
publish-tag-and-latest:
needs: build
runs-on: ubuntu-latest
#if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: docker-image
path: /tmp

- name: Download README.md
uses: actions/download-artifact@v4
with:
name: readme
#path: /home/runner/work/fdsnws-fetcher/fdsnws-fetcher
path: /home/runner/work/_temp/_github_home
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Login to DockerHub
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Load Docker image
run: docker load -i /tmp/image.tar

- name: Tag and push Docker image
run: |
#IMAGE_TAG=${GITHUB_REF#refs/tags/v}
IMAGE_TAG="tmp"
docker tag ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:$IMAGE_TAG
#docker push ${{ env.IMAGE_NAME }}:latest
docker push ${{ env.IMAGE_NAME }}:$IMAGE_TAG
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
#tags: ${{ env.IMAGE_NAME }}:latest
tags: ${{ steps.meta.outputs.tags }}
#platforms: linux/amd64,linux/arm64
labels: ${{ steps.meta.outputs.labels }}

- name: Push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
Expand All @@ -99,15 +73,9 @@ jobs:
with:
provider: dockerhub
destination_container_repo: ${{ env.IMAGE_NAME }}
readme_file: '/github/home/README.md'
readme_file: 'README.md'
short_description: 'Docker image used to retrieve date from FDSN nodes.'

# - name: Publish Docker description (README.md) to Docker Hub
# run: |
# wget -O docker-pushrm "https://github.com/christian-korneck/docker-pushrm/releases/download/v1.7.0/docker-pushrm_linux_amd64"
# chmod +x docker-pushrm
# ./docker-pushrm --file README.md ${{ env.IMAGE_NAME }}

test-publiccode:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 2a71436

Please sign in to comment.