Skip to content

Commit

Permalink
chore: Migrate CI from Drone to Github Actions (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
papey committed Jul 28, 2024
1 parent 79bbc02 commit a7d2ffa
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 87 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/elixir.yml

This file was deleted.

94 changes: 94 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build & Test

on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- "master"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
elixir-version: '1.17'
otp-version: '26.0'

- name: Install dependencies
run: mix deps.get

- name: Build
run: mix compile

test:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@61e01a43a562a89bfc54c7f9a378ff67b03e4a21 # v1.16.0
with:
elixir-version: '1.17'
otp-version: '26.0'

- name: Install dependencies
run: mix deps.get

- name: Test
run: mix test --no-start

container:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4

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

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

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Resolve image tag
id: tag
run: |
if [[ "${{ github.ref }}" =~ "refs/tags/" ]]; then
TAG=${{ github.ref_name }}
else
TAG="latest"
fi
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
push: true
tags: papey/o2m:${{ env.TAG }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ env.TAG }}
org.opencontainers.image.authors="Wilfried OLLIVIER"
org.opencontainers.image.title="trostani"
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.licences="Unlicense"
24 changes: 6 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,9 @@ FROM elixir:1.17 as builder

RUN apt-get update && apt-get install -y openssl

# Declare args
ARG REVISION
ARG RELEASE_TAG

# Ensure mix is in prod mode
ENV MIX_ENV=prod

# image-spec annotations using labels
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.source="https://github.com/papey/o2m"
LABEL org.opencontainers.image.revision=${GIT_COMMIT_SHA}
LABEL org.opencontainers.image.version=${RELEASE_TAG}
LABEL org.opencontainers.image.authors="Wilfried OLLIVIER"
LABEL org.opencontainers.image.title="o2m"
LABEL org.opencontainers.image.description="o2m runtime"
LABEL org.opencontainers.image.licences="Unlicense"

# Create src dir
RUN mkdir /opt/o2m

Expand Down Expand Up @@ -52,11 +38,8 @@ RUN apt-get update -y \
&& apt-get install -y openssl \
libtinfo-dev \
ffmpeg \
python3 \
python3-pip
pipx

# Install latest yt-dlp from github
RUN pip3 install yt-dlp

# Copy over the build artifact from the previous step and create a non root user
RUN useradd o2m
Expand All @@ -74,6 +57,11 @@ RUN chown -R o2m:o2m ./prod

USER o2m

# Install latest yt-dlp from github
RUN pipx install yt-dlp

ENV PATH="${HOME}/.local/bin:${PATH}"

# default arg
CMD ["start"]

Expand Down
41 changes: 0 additions & 41 deletions build/ci/drone.yml

This file was deleted.

0 comments on commit a7d2ffa

Please sign in to comment.