WIP: GitHub Action #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: | |
- '**' | |
tags: | |
- 'v*.*.*' | |
env: | |
IMAGE_NAME: ingv/fdsnws-fetcher | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
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 | |
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 | |
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: /tmp | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
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: Push README to Dockerhub | |
uses: christian-korneck/update-container-description-action@v1 | |
env: | |
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_PASS: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
with: | |
provider: dockerhub | |
destination_container_repo: ${{ env.IMAGE_NAME }} | |
readme_file: '/tmp/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: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Run publiccode parser | |
run: | | |
docker run -i --rm italia/publiccode-parser-go /dev/stdin < publiccode.yml |