-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
64 lines (64 loc) · 2.15 KB
/
action.yaml
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
name: 'Rust GitHub Action'
description: 'GitHub Action that builds Rust code and creates a thin Docker image'
inputs:
app-name:
description: 'App name (from Cargo.toml)'
required: true
default: 'test_app'
output-file-name:
description: 'Name of the output file (without extension)'
required: true
default: 'app'
outputs:
output_file_path:
description: "Output file path"
value: ${{ steps.save.outputs.output_file_path }}
runs:
using: "composite"
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::Support Linux Only"
exit 1
# - name: List Paths (debug)
# run: |
# echo "PATH = $PATH"
# echo "Workspace = ${{ github.workspace }}"
# echo "Action path = ${{ github.action_path }}"
# shell: bash
## TODO: if cache_from type=gha does not work, use type=local in compose.yaml and trying the following:
# - name: Create .cache directory
# run: mkdir -p ./.cache/
# - name: Set up cargo cache
# uses: actions/cache@v3
# continue-on-error: false
# with:
# path: ./.cache/
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# restore-keys: ${{ runner.os }}-cargo-
#
- name: Build the container
run: |
docker build --target final --tag final-app \
--build-arg RUST_VERSION=1.75 --build-arg APP_NAME=${{ inputs.app-name }} \
--platform linux/amd64 \
--cache-from "rust:1.75-alpine" \
--cache-from "alpine:3.19" \
--cache-from "type=gha" \
--cache-to "type=gha,mode=max" \
--file ${{ github.action_path }}/Dockerfile ${{ github.workspace }}
shell: bash
- name: Display built images (debug)
run: docker image ls
shell: bash
- name: Save the container
id: save
run: |
docker save final-app | zip ${{ inputs.output-file-name }}.tar.zip -
echo "output_file_path=${{ github.workspace }}/${{ inputs.output-file-name }}.tar.zip" >> "$GITHUB_OUTPUT"
shell: bash
branding:
icon: 'package'
color: 'green'