-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (118 loc) · 3.9 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Release
on:
release:
types: [prereleased]
push:
branches:
- main
- v*
- dev*
paths:
- "app.py"
- "Containerfile"
- "requirements.txt"
- "templates/index.html"
- ".github/workflows/release.yml"
jobs:
build-ghcr:
name: Build And Push to ghcr.io
runs-on: ubuntu-latest
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
IMAGE_REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
steps:
- uses: actions/checkout@v3
- name: Log in to ghcr.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
registry: ${{ env.IMAGE_REGISTRY }}
- name: Get Information
id: information
env:
PIP_MIRROR_URL: ${{ secrets.PIP_MIRROR_URL }}
run: |
if [[ -z "${PIP_MIRROR_URL}" ]]; then
PIP_MIRROR_URL="https://pypi.org/simple"
fi
echo "PIP_MIRROR_URL: ${PIP_MIRROR_URL}"
echo "PIP_MIRROR_URL=$PIP_MIRROR_URL" >> $GITHUB_OUTPUT
BUILD_TAG="latest"
echo "tag: ${BUILD_TAG}"
if [[ "${{ github.ref_name }}" != "main" ]]; then
BUILD_TAG="${{ github.ref_name }}-${{ matrix.arch }}"
fi
echo "BUILD_TAG: ${BUILD_TAG}"
echo "BUILD_TAG=$BUILD_TAG" >> $GITHUB_OUTPUT
sudo apt install qemu-user-static -y
- name: Buildah Action
id: build-image
uses: redhat-actions/buildah-build@v2
env:
PIP_MIRROR_URL: ${{ steps.information.outputs.PIP_MIRROR_URL }}
with:
image: ${{ env.REPOSITORY }}
tags: "${{ steps.information.outputs.BUILD_TAG }}"
containerfiles: |
./Containerfile
build-args: |
PIP_MIRROR_URL=${{ env.PIP_MIRROR_URL }}
platforms: linux/amd64,linux/arm64
context: .
extra-args: |
--squash
--timestamp 0
- name: Push To ghcr.io
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
build-docker:
name: Build And Push Docker Hub
runs-on: ubuntu-latest
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
IMAGE: filetas
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Get Information
id: information
env:
PIP_MIRROR_URL: ${{ secrets.PIP_MIRROR_URL }}
run: |
if [[ -z "${PIP_MIRROR_URL}" ]]; then
PIP_MIRROR_URL="https://pypi.org/simple"
fi
echo "PIP_MIRROR_URL: ${PIP_MIRROR_URL}"
echo "PIP_MIRROR_URL=$PIP_MIRROR_URL" >> $GITHUB_OUTPUT
BUILD_TAG="${{ github.ref_name }}-${{ matrix.arch }}"
echo "tag: ${BUILD_TAG}"
if [[ "${{ github.ref_name }}" = "main" ]]; then
BUILD_TAG="latest"
fi
echo "BUILD_TAG: ${BUILD_TAG}"
echo "BUILD_TAG=$BUILD_TAG" >> $GITHUB_OUTPUT
docker buildx create --use
- name: Build and push
id: dockerbuild
uses: docker/build-push-action@v4
with:
build-args: |
PIP_MIRROR_URL=${{ steps.information.outputs.PIP_MIRROR_URL }}
context: .
file: ./Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE }}:${{ steps.information.outputs.BUILD_TAG }}