1.2.7 #58
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: | |
- 'master' | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
build: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Read version | |
id: version | |
uses: martinbeentjes/npm-get-version-action@master | |
with: | |
path: . | |
- name: Build image | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: | | |
chlod/pagasa-parser-web:latest | |
chlod/pagasa-parser-web:${{ steps.version.outputs.current-version }} | |
outputs: type=docker,dest=/tmp/pagasa-parser-web.image.tar | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
- name: Upload Docker image to artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: image | |
path: /tmp/pagasa-parser-web.image.tar | |
analysis: | |
name: Analyze image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download Docker image to artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: image | |
path: /tmp | |
- name: Load image | |
run: | | |
docker load --input /tmp/pagasa-parser-web.image.tar | |
docker image ls -a | |
- name: Dive | |
uses: yuichielectric/dive-action@0.0.4 | |
with: | |
image: "chlod/pagasa-parser-web:latest" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
push: | |
name: Push to Docker hub | |
runs-on: ubuntu-latest | |
needs: analysis | |
# Only push when tagged | |
if: github.ref_type == 'tag' || ( | |
github.event.pusher.name == 'ChlodAlejandro' | |
&& startsWith(github.event.head_commit.message, '[rw]')) | |
# rewrite | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Download Docker image to artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: image | |
path: /tmp | |
- name: Load image | |
run: | | |
docker load --input /tmp/pagasa-parser-web.image.tar | |
docker image ls -a | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Read version | |
id: version | |
uses: martinbeentjes/npm-get-version-action@master | |
with: | |
path: . | |
- name: Push image | |
id: docker_build | |
run: | | |
docker push chlod/pagasa-parser-web:latest | |
docker push chlod/pagasa-parser-web:${{ steps.version.outputs.current-version }} |