Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(docker): Add workflow to build and publish images #146

Merged
merged 18 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker Image CI

on:
push:
branches:
- 'main'
paths:
- 'taqueria-plugin-flextesa/docker/*'
tags:
- 'v*'
pull_request:
branches:
- 'main'
paths:
- 'taqueria-plugin-flextesa/docker/*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/main' || github.run_number }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

env:
REGISTRY: ghcr.io

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Registry login
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: image-metadata
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/taqueria-flextesa
tags: |
type=ref,event=branch
type=ref,event=pr,suffix=-{{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: taqueria-plugin-flextesa/docker
push: true
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}

- name: Comment on PR
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'The latest docker name:tag for this PR is ***${{ steps.image-metadata.outputs.tags }}*** :whale: :ship:'
})
6 changes: 3 additions & 3 deletions taqueria-plugin-flextesa/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM oxheadalpha/flextesa:latest
RUN mkdir /app
WORKDIR /app
COPY startFlextesa.js /app/
RUN apk add net-tools && apk add nodejs && apk add npm
CMD node /app/startFlextesa.js
COPY startFlextesa.ts /app/
RUN apk add net-tools nodejs npm
CMD node /app/startFlextesa.ts